简化五图层插件
This commit is contained in:
parent
73de017d92
commit
9ab7150088
@ -53,6 +53,8 @@ function editor() {
|
||||
lastUsedCtx: document.getElementById('lastUsed').getContext('2d'),
|
||||
lockMode: document.getElementById('lockMode'),
|
||||
gameInject: document.getElementById('gameInject'),
|
||||
maps: ['bgmap', 'fgmap', 'map'],
|
||||
canvas: ['bg', 'fg'],
|
||||
};
|
||||
|
||||
this.uivalues={
|
||||
@ -266,11 +268,9 @@ editor.prototype.mapInit = function () {
|
||||
editor.map[y][x] = 0;
|
||||
}
|
||||
}
|
||||
editor.fgmap=JSON.parse(JSON.stringify(editor.map));
|
||||
editor.bgmap=JSON.parse(JSON.stringify(editor.map));
|
||||
editor.currentFloorData.map = editor.map;
|
||||
editor.currentFloorData.fgmap = editor.fgmap;
|
||||
editor.currentFloorData.bgmap = editor.bgmap;
|
||||
editor.dom.maps.forEach(function (one) {
|
||||
editor.currentFloorData[one] = editor[one] = JSON.parse(JSON.stringify(editor.map));
|
||||
});
|
||||
editor.currentFloorData.firstArrive = [];
|
||||
editor.currentFloorData.eachArrive = [];
|
||||
editor.currentFloorData.events = {};
|
||||
@ -282,7 +282,7 @@ editor.prototype.mapInit = function () {
|
||||
}
|
||||
|
||||
editor.prototype.changeFloor = function (floorId, callback) {
|
||||
for(var ii=0,name;name=['map','bgmap','fgmap'][ii];ii++){
|
||||
for(var ii=0,name;name=editor.dom.maps[ii];ii++){
|
||||
var mapArray=editor[name].map(function (v) {
|
||||
return v.map(function (v) {
|
||||
return v.idnum || v || 0
|
||||
@ -386,10 +386,11 @@ editor.prototype.updateMap = function () {
|
||||
|
||||
var updateMap = function () {
|
||||
core.removeGlobalAnimate();
|
||||
core.clearMap('bg');
|
||||
editor.dom.canvas.forEach(function (one) {
|
||||
core.clearMap(one);
|
||||
});
|
||||
core.clearMap('event');
|
||||
core.clearMap('event2');
|
||||
core.clearMap('fg');
|
||||
core.maps._drawMap_drawAll();
|
||||
}
|
||||
updateMap();
|
||||
@ -418,12 +419,10 @@ editor.prototype.updateMap = function () {
|
||||
// 绘制地图 start
|
||||
for (var y = 0; y < editor.map.length; y++) {
|
||||
for (var x = 0; x < editor.map[0].length; x++) {
|
||||
var tileInfo = editor.map[y][x];
|
||||
drawTile(editor.dom.evCtx, x, y, tileInfo);
|
||||
tileInfo = editor.fgmap[y][x];
|
||||
drawTile(editor.dom.fgCtx, x, y, tileInfo);
|
||||
tileInfo = editor.bgmap[y][x];
|
||||
drawTile(editor.dom.bgCtx, x, y, tileInfo);
|
||||
drawTile(editor.dom.evCtx, x, y, editor.map[y][x]);
|
||||
editor.dom.canvas.forEach(function (one) {
|
||||
drawTile(editor.dom[one + 'Ctx'], x, y, editor[one+'map'][y][x]);
|
||||
});
|
||||
}
|
||||
}
|
||||
// 绘制地图 end
|
||||
|
||||
@ -530,7 +530,7 @@ editor_datapanel_wrapper = function (editor) {
|
||||
newFloorData.height = height;
|
||||
|
||||
// Step 2:更新map, bgmap和fgmap
|
||||
["bgmap", "fgmap", "map"].forEach(function (name) {
|
||||
editor.dom.maps.forEach(function (name) {
|
||||
newFloorData[name] = [];
|
||||
if (currentFloorData[name] && currentFloorData[name].length > 0) {
|
||||
for (var j = 0; j < height; ++j) {
|
||||
|
||||
@ -83,7 +83,9 @@ editor_file_wrapper = function (editor) {
|
||||
var datastr = ['main.floors.', floorId, '=\n'];
|
||||
|
||||
var tempJsonObj = Object.assign({}, floorData);
|
||||
var tempMap = [['map', editor.util.guid()], ['bgmap', editor.util.guid()], ['fgmap', editor.util.guid()]];
|
||||
var tempMap = editor.dom.maps.map(function (one) {
|
||||
return [one, editor.util.guid()]
|
||||
});
|
||||
tempMap.forEach(function (v) {
|
||||
v[2] = tempJsonObj[v[0]];
|
||||
tempJsonObj[v[0]] = v[1];
|
||||
@ -164,11 +166,8 @@ editor_file = function (editor, callback) {
|
||||
/* if (!isset(editor.currentFloorId) || !isset(editor.currentFloorData)) {
|
||||
callback('未选中文件或无数据');
|
||||
} */
|
||||
var filename = 'project/floors/' + editor.currentFloorId + '.js';
|
||||
var datastr = ['main.floors.', editor.currentFloorId, '=\n'];
|
||||
|
||||
if (core.floorIds.indexOf(editor.currentFloorId) >= 0) {
|
||||
for(var ii=0,name;name=['map','bgmap','fgmap'][ii];ii++){
|
||||
for(var ii=0,name;name=editor.dom.maps[ii];ii++){
|
||||
var mapArray=editor[name].map(function (v) {
|
||||
return v.map(function (v) {
|
||||
return v.idnum || v || 0
|
||||
@ -667,9 +666,7 @@ editor_file = function (editor, callback) {
|
||||
Object.keys(editor.file.comment._data.floors._data.loc._data).forEach(function (v) {
|
||||
delete(locObj[v]);
|
||||
});
|
||||
delete(locObj.map);
|
||||
delete(locObj.bgmap);
|
||||
delete(locObj.fgmap);
|
||||
editor.dom.maps.forEach(function (one) { delete locObj[one]; });
|
||||
return locObj;
|
||||
})(),
|
||||
editor.file.comment._data.floors._data.floor,
|
||||
|
||||
@ -151,7 +151,8 @@ editor_game_wrapper = function (editor, main, core) {
|
||||
// 补出缺省的数据
|
||||
editor.currentFloorData.autoEvent = editor.currentFloorData.autoEvent || {};
|
||||
//
|
||||
for (var ii = 0, name; name = ['bgmap', 'fgmap'][ii]; ii++) {
|
||||
for (var ii = 0, name; name = editor.dom.canvas[ii]; ii++) {
|
||||
name += 'map';
|
||||
var mapArray = editor.currentFloorData[name];
|
||||
if (!mapArray || JSON.stringify(mapArray) == JSON.stringify([])) {//未设置或空数组
|
||||
//与editor.map同形的全0
|
||||
|
||||
@ -717,29 +717,27 @@ editor_mappanel_wrapper = function (editor) {
|
||||
editor.brushMod = editor.dom.brushMod4.value;
|
||||
}
|
||||
|
||||
editor.uifunctions.setLayerMod = function (layer) {
|
||||
editor.layerMod = layer;
|
||||
var canvas = ['ev', 'ev2'].concat(editor.dom.canvas);
|
||||
canvas.forEach(function (one) {
|
||||
editor.dom[one+'c'].style.opacity = 1;
|
||||
});
|
||||
if (layer != 'map') {
|
||||
canvas.filter(function (one) {
|
||||
return one + 'map' != editor.layerMod
|
||||
}).forEach(function (one) {
|
||||
editor.dom[one+'c'].style.opacity = 0.3;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* editor.dom.layerMod.onchange
|
||||
* 切换编辑的层
|
||||
*/
|
||||
editor.uifunctions.layerMod_onchange = function () {
|
||||
editor.layerMod = editor.dom.layerMod.value;
|
||||
[editor.dom.bgc, editor.dom.fgc, editor.dom.evc, editor.dom.ev2c].forEach(function (x) {
|
||||
x.style.opacity = 1;
|
||||
});
|
||||
|
||||
// 手机端....
|
||||
if (editor.isMobile) {
|
||||
if (editor.dom.layerMod.value == 'bgmap') {
|
||||
[editor.dom.fgc, editor.dom.evc, editor.dom.ev2c].forEach(function (x) {
|
||||
x.style.opacity = 0.3;
|
||||
});
|
||||
}
|
||||
if (editor.dom.layerMod.value == 'fgmap') {
|
||||
[editor.dom.bgc, editor.dom.evc, editor.dom.ev2c].forEach(function (x) {
|
||||
x.style.opacity = 0.3;
|
||||
});
|
||||
}
|
||||
}
|
||||
editor.uifunctions.setLayerMod(editor.dom.layerMod.value);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -747,11 +745,7 @@ editor_mappanel_wrapper = function (editor) {
|
||||
* 切换编辑的层
|
||||
*/
|
||||
editor.uifunctions.layerMod2_onchange = function () {
|
||||
editor.layerMod = editor.dom.layerMod2.value;
|
||||
[editor.dom.fgc, editor.dom.evc, editor.dom.ev2c].forEach(function (x) {
|
||||
x.style.opacity = 0.3;
|
||||
});
|
||||
editor.dom.bgc.style.opacity = 1;
|
||||
editor.uifunctions.setLayerMod('bgmap');
|
||||
}
|
||||
|
||||
/**
|
||||
@ -759,11 +753,7 @@ editor_mappanel_wrapper = function (editor) {
|
||||
* 切换编辑的层
|
||||
*/
|
||||
editor.uifunctions.layerMod3_onchange = function () {
|
||||
editor.layerMod = editor.dom.layerMod3.value;
|
||||
[editor.dom.bgc, editor.dom.evc, editor.dom.ev2c].forEach(function (x) {
|
||||
x.style.opacity = 0.3;
|
||||
});
|
||||
editor.dom.fgc.style.opacity = 1;
|
||||
editor.uifunctions.setLayerMod('fgmap');
|
||||
}
|
||||
|
||||
/**
|
||||
@ -977,11 +967,10 @@ editor_mappanel_wrapper = function (editor) {
|
||||
}
|
||||
|
||||
editor.constructor.prototype.savePreMap = function () {
|
||||
var dt = {
|
||||
map: editor.map,
|
||||
fgmap: editor.fgmap,
|
||||
bgmap: editor.bgmap,
|
||||
};
|
||||
var dt = {};
|
||||
editor.dom.maps.forEach(function (one) {
|
||||
dt[one] = editor[one];
|
||||
});
|
||||
if (editor.uivalues.preMapData.length == 0
|
||||
|| !core.same(editor.uivalues.preMapData[editor.uivalues.preMapData.length - 1], dt)) {
|
||||
editor.uivalues.preMapData.push(core.clone(dt));
|
||||
|
||||
@ -190,9 +190,9 @@ editor_ui_wrapper = function (editor) {
|
||||
e.preventDefault();
|
||||
if (editor.uivalues.preMapData.length > 0) {
|
||||
var data = editor.uivalues.preMapData.pop();
|
||||
editor.map = JSON.parse(JSON.stringify(data.map));
|
||||
editor.fgmap = JSON.parse(JSON.stringify(data.fgmap));
|
||||
editor.bgmap = JSON.parse(JSON.stringify(data.bgmap));
|
||||
editor.dom.maps.forEach(function (one) {
|
||||
editor[one] = JSON.parse(JSON.stringify(data[one]));
|
||||
});
|
||||
editor.updateMap();
|
||||
editor.uivalues.postMapData.push(data);
|
||||
editor.uifunctions.highlightSaveFloorButton();
|
||||
@ -205,9 +205,9 @@ editor_ui_wrapper = function (editor) {
|
||||
e.preventDefault();
|
||||
if (editor.uivalues.postMapData.length > 0) {
|
||||
var data = editor.uivalues.postMapData.pop();
|
||||
editor.map = JSON.parse(JSON.stringify(data.map));
|
||||
editor.fgmap = JSON.parse(JSON.stringify(data.fgmap));
|
||||
editor.bgmap = JSON.parse(JSON.stringify(data.bgmap));
|
||||
editor.dom.maps.forEach(function (one) {
|
||||
editor[one] = JSON.parse(JSON.stringify(data[one]));
|
||||
});
|
||||
editor.updateMap();
|
||||
editor.uivalues.preMapData.push(data);
|
||||
editor.uifunctions.highlightSaveFloorButton();
|
||||
@ -709,6 +709,7 @@ editor_ui_wrapper = function (editor) {
|
||||
html += '<br/>';
|
||||
});
|
||||
html += "</p>";
|
||||
html += "<p style='margin-left: 10px'><small>如果文件未在此列表显示,请检查文件名是否合法(只能由数字字母下划线横线和点组成),后缀名是否正确。</small></p>";
|
||||
uievent.elements.extraBody.innerHTML = html;
|
||||
});
|
||||
}
|
||||
|
||||
@ -1487,6 +1487,7 @@ maps.prototype._removeBlockFromMap = function (floorId, block) {
|
||||
if (block.event.cls == 'autotile') {
|
||||
core.drawMap();
|
||||
} else {
|
||||
var x = block.x, y = block.y;
|
||||
core.removeGlobalAnimate(x, y);
|
||||
core.clearMap('event', x * 32, y * 32, 32, 32);
|
||||
var height = block.event.height || 32;
|
||||
|
||||
@ -30,11 +30,6 @@ main.floors.sample0=
|
||||
"background": "winskin.png",
|
||||
"time": 0
|
||||
},
|
||||
{
|
||||
"type": "setValue",
|
||||
"name": "status:animate",
|
||||
"value": "true"
|
||||
},
|
||||
"\t[样板提示]首次到达某层可以触发 firstArrive 事件,该事件可类似于RMXP中的“自动执行脚本”。\n\n本事件支持一切的事件类型,常常用来触发对话,例如:",
|
||||
"\t[hero]\b[up,hero]我是谁?我从哪来?我又要到哪去?",
|
||||
"\t[仙子,fairy]你问我...?我也不知道啊...",
|
||||
|
||||
@ -324,6 +324,8 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 =
|
||||
editor.dom.bg2Ctx = core.canvas.bg2;
|
||||
editor.dom.fg2c = core.canvas.fg2.canvas;
|
||||
editor.dom.fg2Ctx = core.canvas.fg2;
|
||||
editor.dom.maps.push('bg2map', 'fg2map');
|
||||
editor.dom.canvas.push('bg2', 'fg2');
|
||||
|
||||
// 默认全空
|
||||
var defaultMap = [];
|
||||
@ -400,255 +402,13 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 =
|
||||
return;
|
||||
}
|
||||
_isEditorInit = true;
|
||||
// 编辑器更新地图
|
||||
editor.updateMap = function () {
|
||||
var blocks = core.maps._mapIntoBlocks(editor.map.map(function (v) {
|
||||
return v.map(function (v) {
|
||||
try {
|
||||
return v.idnum || v || 0;
|
||||
} catch (e) {
|
||||
console.log("Unable to read idnum from " + v);
|
||||
return 0;
|
||||
}
|
||||
});
|
||||
}), { 'events': editor.currentFloorData.events }, editor.currentFloorId);
|
||||
core.status.thisMap.blocks = blocks;
|
||||
|
||||
var updateMap = function () {
|
||||
// 新增图层也需要刷新
|
||||
core.removeGlobalAnimate();
|
||||
core.clearMap('bg');
|
||||
core.clearMap('bg2');
|
||||
core.clearMap('event');
|
||||
core.clearMap('event2');
|
||||
core.clearMap('fg');
|
||||
core.clearMap('fg2');
|
||||
core.maps._drawMap_drawAll();
|
||||
};
|
||||
updateMap();
|
||||
|
||||
var drawTile = function (ctx, x, y, tileInfo) { // 绘制一个普通块
|
||||
|
||||
//ctx.clearRect(x*32, y*32, 32, 32);
|
||||
if (tileInfo == 0) return;
|
||||
|
||||
if (typeof (tileInfo) == typeof ([][0]) || !Object.prototype.hasOwnProperty.call(tileInfo, 'idnum')) { //未定义块画红块
|
||||
if (typeof (tileInfo) != typeof ([][0]) && Object.prototype.hasOwnProperty.call(tileInfo, 'images')) {
|
||||
ctx.drawImage(core.material.images[tileInfo.images], 0, tileInfo.y * 32, 32, 32, x * 32, y * 32, 32, 32);
|
||||
}
|
||||
ctx.strokeStyle = 'red';
|
||||
var OFFSET = 2;
|
||||
ctx.lineWidth = OFFSET;
|
||||
ctx.strokeRect(x * 32 + OFFSET, y * 32 + OFFSET, 32 - OFFSET * 2, 32 - OFFSET * 2);
|
||||
ctx.font = "30px Verdana";
|
||||
ctx.textAlign = 'center';
|
||||
ctx.fillStyle = 'red';
|
||||
ctx.fillText("?", x * 32 + 16, y * 32 + 27);
|
||||
return;
|
||||
}
|
||||
//ctx.drawImage(core.material.images[tileInfo.images], 0, tileInfo.y*32, 32, 32, x*32, y*32, 32, 32);
|
||||
};
|
||||
// 绘制地图 start
|
||||
for (var y = 0; y < editor.map.length; y++) {
|
||||
for (var x = 0; x < editor.map[0].length; x++) {
|
||||
var tileInfo = editor.map[y][x];
|
||||
drawTile(editor.dom.evCtx, x, y, tileInfo);
|
||||
tileInfo = editor.fgmap[y][x];
|
||||
drawTile(editor.dom.fgCtx, x, y, tileInfo);
|
||||
tileInfo = editor.bgmap[y][x];
|
||||
drawTile(editor.dom.bgCtx, x, y, tileInfo);
|
||||
// 新增图层的未定义图块绘制
|
||||
tileInfo = editor.fg2map[y][x];
|
||||
drawTile(editor.dom.fgCtx, x, y, tileInfo);
|
||||
tileInfo = editor.bg2map[y][x];
|
||||
drawTile(editor.dom.bgCtx, x, y, tileInfo);
|
||||
}
|
||||
}
|
||||
// 绘制地图 end
|
||||
|
||||
// 下面这行是2.7新增内容
|
||||
editor.drawEventBlock();
|
||||
this.updateLastUsedMap();
|
||||
};
|
||||
// 编辑器写入文件
|
||||
editor.file.saveFloor = function (floorData, callback) {
|
||||
//callback(err:String)
|
||||
var floorId = floorData.floorId;
|
||||
var filename = 'project/floors/' + floorId + '.js';
|
||||
var datastr = ['main.floors.', floorId, '=\n'];
|
||||
|
||||
var tempJsonObj = Object.assign({}, floorData);
|
||||
// 多写入两个图层
|
||||
var tempMap = [
|
||||
['map', editor.util.guid()],
|
||||
['bgmap', editor.util.guid()],
|
||||
['bg2map', editor.util.guid()],
|
||||
['fgmap', editor.util.guid()],
|
||||
['fg2map', editor.util.guid()]
|
||||
];
|
||||
tempMap.forEach(function (v) {
|
||||
v[2] = tempJsonObj[v[0]];
|
||||
tempJsonObj[v[0]] = v[1];
|
||||
});
|
||||
var tempJson = JSON.stringify(tempJsonObj, editor.game.replacerForSaving, 4);
|
||||
tempMap.forEach(function (v) {
|
||||
tempJson = tempJson.replace('"' + v[1] + '"', '[\n' + editor.file.formatMap(v[2], v[0] != 'map') + '\n]');
|
||||
});
|
||||
datastr = datastr.concat([tempJson]);
|
||||
datastr = datastr.join('');
|
||||
editor.file.alertWhenCompress();
|
||||
editor.fs.writeFile(filename, editor.util.encode64(datastr), 'base64', function (err, data) {
|
||||
editor.addUsedFlags(datastr);
|
||||
callback(err);
|
||||
});
|
||||
};
|
||||
editor.file.saveFloorFile = function (callback) {
|
||||
//callback(err:String)
|
||||
editor.util.checkCallback(callback);
|
||||
/* if (!isset(editor.currentFloorId) || !isset(editor.currentFloorData)) {
|
||||
callback('未选中文件或无数据');
|
||||
} */
|
||||
if (core.floorIds.indexOf(editor.currentFloorId) >= 0) {
|
||||
// 增加背景层2与前景层2的当前地图数据绑定
|
||||
for (var ii = 0, name; name = ['map', 'bgmap', 'bg2map', 'fgmap', 'fg2map'][ii]; ii++) {
|
||||
var mapArray = editor[name].map(function (v) {
|
||||
return v.map(function (v) {
|
||||
return v.idnum || v || 0;
|
||||
})
|
||||
});
|
||||
editor.currentFloorData[name] = mapArray;
|
||||
}
|
||||
}
|
||||
editor.file.saveFloor(editor.currentFloorData, callback);
|
||||
};
|
||||
// 编辑器取得地图数据
|
||||
editor.game.fetchMapFromCore = function () {
|
||||
var mapArray = core.getMapArray(core.status.floorId, true);
|
||||
// 2.6.6原写法:var mapArray = core.maps.saveMap(core.status.floorId);
|
||||
editor.map = mapArray.map(function (v) {
|
||||
return v.map(function (v) {
|
||||
var x = parseInt(v),
|
||||
y = editor.indexs[x];
|
||||
if (y == null) {
|
||||
printe("素材数字" + x + "未定义。是不是忘了注册,或者接档时没有覆盖icons.js和maps.js?");
|
||||
y = [0];
|
||||
}
|
||||
return editor.ids[y[0]];
|
||||
});
|
||||
});
|
||||
editor.currentFloorId = core.status.floorId;
|
||||
editor.currentFloorData = core.floors[core.status.floorId];
|
||||
// 补出缺省的数据
|
||||
editor.currentFloorData.autoEvent = editor.currentFloorData.autoEvent || {};
|
||||
// 前景层2与背景层2的editor地图数据绑定
|
||||
for (var ii = 0, name; name = ['bgmap', 'bg2map', 'fgmap', 'fg2map'][ii]; ii++) {
|
||||
var mapArray = editor.currentFloorData[name];
|
||||
if (!mapArray || JSON.stringify(mapArray) == JSON.stringify([])) { //未设置或空数组
|
||||
//与editor.map同形的全0
|
||||
mapArray = eval('[' + Array(editor.map.length + 1).join('[' + Array(editor.map[0].length + 1).join('0,') + '],') + ']');
|
||||
}
|
||||
editor[name] = mapArray.map(function (v) {
|
||||
return v.map(function (v) {
|
||||
var x = parseInt(v),
|
||||
y = editor.indexs[x];
|
||||
if (y == null) {
|
||||
printe("素材数字" + x + "未定义。是不是忘了注册,或者接档时没有覆盖icons.js和maps.js?");
|
||||
y = [0];
|
||||
}
|
||||
return editor.ids[y[0]];
|
||||
});
|
||||
});
|
||||
}
|
||||
};
|
||||
// 选中背景层2或前景层2时其他图层的透明度变更
|
||||
editor.uifunctions.layerMod_onchange = function () {
|
||||
editor.layerMod = editor.dom.layerMod.value;
|
||||
[editor.dom.bg2c, editor.dom.fg2c, editor.dom.bgc, editor.dom.fgc, editor.dom.evc, editor.dom.ev2c].forEach(function (x) {
|
||||
x.style.opacity = 1;
|
||||
});
|
||||
|
||||
// 手机端....
|
||||
if (editor.isMobile) {
|
||||
var arr = ["bg", "bg2", "fg", "fg2"];
|
||||
for (var i = 0; i < arr.length; i++) {
|
||||
if (editor.dom.layerMod.value == arr[i] + "map") {
|
||||
var newArr = arr.concat(["ev", "ev2"]);
|
||||
for (var ii = 0; ii < newArr.length; ii++) {
|
||||
if (ii != i) editor.dom[newArr[ii] + "c"].style.opacity = 0.3;
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
editor.uifunctions.layerMod2_onchange = function () {
|
||||
editor.layerMod = editor.dom.layerMod2.value;
|
||||
[editor.dom.bg2c, editor.dom.fg2c, editor.dom.fgc, editor.dom.evc, editor.dom.ev2c].forEach(function (x) {
|
||||
x.style.opacity = 0.3;
|
||||
});
|
||||
editor.dom.bgc.style.opacity = 1;
|
||||
};
|
||||
editor.uifunctions.layerMod3_onchange = function () {
|
||||
editor.layerMod = editor.dom.layerMod3.value;
|
||||
[editor.dom.bg2c, editor.dom.fg2c, editor.dom.bgc, editor.dom.evc, editor.dom.ev2c].forEach(function (x) {
|
||||
x.style.opacity = 0.3;
|
||||
});
|
||||
editor.dom.fgc.style.opacity = 1;
|
||||
};
|
||||
// 当背景层2按钮选中情况发生变动
|
||||
editor.uifunctions.layerMod4_onchange = function () {
|
||||
editor.layerMod = editor.dom.layerMod4.value;
|
||||
[editor.dom.fgc, editor.dom.fg2c, editor.dom.bgc, editor.dom.evc, editor.dom.ev2c].forEach(function (x) {
|
||||
x.style.opacity = 0.3;
|
||||
});
|
||||
editor.dom.bg2c.style.opacity = 1;
|
||||
};
|
||||
// 当前景层2按钮选中情况发生变动
|
||||
editor.uifunctions.layerMod5_onchange = function () {
|
||||
editor.layerMod = editor.dom.layerMod5.value;
|
||||
[editor.dom.bg2c, editor.dom.fgc, editor.dom.bgc, editor.dom.evc, editor.dom.ev2c].forEach(function (x) {
|
||||
x.style.opacity = 0.3;
|
||||
});
|
||||
editor.dom.fg2c.style.opacity = 1;
|
||||
};
|
||||
// 绑定onchange
|
||||
editor.dom.layerMod4.onchange = editor.uifunctions.layerMod4_onchange;
|
||||
editor.dom.layerMod5.onchange = editor.uifunctions.layerMod5_onchange;
|
||||
// 编辑器下移动图块
|
||||
editor.constructor.moveBgFg = function (startPos, endPos, name, callback) {
|
||||
if (!startPos || !endPos || ["bgmap", "bg2map", "fgmap", "fg2map"].indexOf(name) < 0) return;
|
||||
if (startPos.x == endPos.x && startPos.y == endPos.y) return;
|
||||
editor[name][endPos.y][endPos.x] = editor[name][startPos.y][startPos.x];
|
||||
editor[name][startPos.y][startPos.x] = 0;
|
||||
editor.updateMap();
|
||||
editor.file.saveFloorFile(function (err) {
|
||||
if (err) {
|
||||
printe(err);
|
||||
throw (err);
|
||||
}
|
||||
printf('移动图块成功');
|
||||
editor.drawPosSelection();
|
||||
if (callback) callback();
|
||||
});
|
||||
};
|
||||
// 编辑器下交换图块
|
||||
editor.constructor.exchangeBgFg = function (startPos, endPos, name, callback) {
|
||||
if (!startPos || !endPos || ["bgmap", "bg2map", "fgmap", "fg2map"].indexOf(name) < 0) return;
|
||||
if (startPos.x == endPos.x && startPos.y == endPos.y) return;
|
||||
var value = editor[name][endPos.y][endPos.x];
|
||||
editor[name][endPos.y][endPos.x] = editor[name][startPos.y][startPos.x];
|
||||
editor[name][startPos.y][startPos.x] = value;
|
||||
editor.updateMap();
|
||||
editor.file.saveFloorFile(function (err) {
|
||||
if (err) {
|
||||
printe(err);
|
||||
throw (err);
|
||||
}
|
||||
printf('交换图块成功');
|
||||
editor.drawPosSelection();
|
||||
if (callback) callback();
|
||||
});
|
||||
editor.dom.layerMod4.onchange = function () {
|
||||
editor.uifunctions.setLayerMod('bg2map');
|
||||
};
|
||||
editor.dom.layerMod5.onchange = function () {
|
||||
editor.uifunctions.setLayerMod('fg2map');
|
||||
}
|
||||
// 继续进行afterCoreReset
|
||||
if (callback) callback();
|
||||
};
|
||||
@ -754,7 +514,7 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 =
|
||||
], "cannotOut", direction))
|
||||
return false;
|
||||
if (this._canMoveHero_checkCannotInOut([
|
||||
extraData.bgArray[ny][nx], extraData.bg2Array[y][x], extraData.fgArray[ny][nx], extraData.fg2Array[y][x], extraData.eventArray[ny][nx]
|
||||
extraData.bgArray[ny][nx], extraData.bg2Array[ny][nx], extraData.fgArray[ny][nx], extraData.fg2Array[ny][nx], extraData.eventArray[ny][nx]
|
||||
], "cannotIn", direction))
|
||||
return false;
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user