Merge pull request #379 from ckcz123/v2.x

V2.x
This commit is contained in:
Zhang Chen 2019-06-09 00:06:26 +08:00 committed by GitHub
commit 9c31563f43
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 57 additions and 31 deletions

View File

@ -190,7 +190,9 @@
从V2.5.2以后,新增了绘制大头像的功能。绘制大头像图的基本写法是`\t[1.png]`或者`\t[标题,1.png]`。
从V2.6开始所有图块都允许只写ID对于非怪物则没有标题。
从V2.6开始所有图块都允许只写ID对于非怪物则仅当图块属性中设置了name才有标题否则不显示标题
另外注意的是名字可以用null从而只显示动画而不显示标题。
``` js
[
@ -204,7 +206,8 @@
"\t[1.png]绘制1.png这个头像图",
"\t[标题,1.png]同时绘制标题和1.png这个头像图",
"\t[sword1]获得铁剑,没有标题",
"\t[man]没有标题的npc动画"
"\t[man]没有标题的npc动画",
"\t[null,greenSlime]只绘制怪物动画而不显示标题"
]
```

View File

@ -531,6 +531,25 @@ editor.prototype.movePos = function (startPos, endPos, callback) {
});
}
editor.prototype.exchangePos = function (startPos, endPos, callback) {
if (!startPos || !endPos) return;
if (startPos.x == endPos.x && startPos.y == endPos.y) return;
var startInfo = editor.copyFromPos(startPos);
var endInfo = editor.copyFromPos(endPos);
editor.pasteToPos(startInfo, endPos);
editor.pasteToPos(endInfo, startPos);
editor.updateMap();
editor.file.saveFloorFile(function (err) {
if (err) {
printe(err);
throw(err)
}
;printf('交换事件成功');
editor.drawPosSelection();
if (callback) callback();
});
}
editor.prototype.clearPos = function (clearPos, pos, callback) {
var fields = Object.keys(editor.file.comment._data.floors._data.loc._data);
pos = pos || editor.pos;

View File

@ -123,7 +123,7 @@ editor.constructor.prototype.listen=function () {
var loc = eToLoc(e);
var pos = locToPos(loc,true);
editor.showMidMenu(e.clientX,e.clientY);
return;
return false;
}
if (!selectBox.isSelected()) {
var loc = eToLoc(e);
@ -137,20 +137,19 @@ editor.constructor.prototype.listen=function () {
uc.strokeStyle = '#FF0000';
uc.lineWidth = 3;
if(editor.isMobile)editor.showMidMenu(e.clientX,e.clientY);
return;
return false;
}
holdingPath = 1;
mouseOutCheck = 2;
setTimeout(clear1);
e.stopPropagation();
uc.clearRect(0, 0, core.__PIXELS__, core.__PIXELS__);
var loc = eToLoc(e);
var pos = locToPos(loc,true);
stepPostfix = [];
stepPostfix.push(pos);
fillPos(pos);
return false;
}
eui.onmousemove = function (e) {
@ -178,14 +177,13 @@ editor.constructor.prototype.listen=function () {
//editor_mode.loc();
//tip.whichShow(1);
// tip.showHelp(6);
return;
return false;
}
if (holdingPath == 0) {
return;
return false;
}
mouseOutCheck = 2;
e.stopPropagation();
var loc = eToLoc(e);
var pos = locToPos(loc,true);
var pos0 = stepPostfix[stepPostfix.length - 1]
@ -204,18 +202,19 @@ editor.constructor.prototype.listen=function () {
stepPostfix.push(pos);
fillPos(pos);
}
return false;
}
eui.onmouseup = function (e) {
if (!selectBox.isSelected()) {
//tip.whichShow(1);
editor.movePos(startPos, endPos);
// editor.movePos(startPos, endPos);
editor.exchangePos(startPos, endPos);
startPos = endPos = null;
uc.clearRect(0, 0, core.__PIXELS__, core.__PIXELS__);
return;
return false;
}
holdingPath = 0;
e.stopPropagation();
if (stepPostfix && stepPostfix.length) {
editor.preMapData = JSON.parse(JSON.stringify({map:editor.map,fgmap:editor.fgmap,bgmap:editor.bgmap}));
if(editor.brushMod!=='line'){
@ -258,6 +257,7 @@ editor.constructor.prototype.listen=function () {
stepPostfix = [];
uc.clearRect(0, 0, core.__PIXELS__, core.__PIXELS__);
}
return false;
}
/*
@ -279,7 +279,6 @@ editor.constructor.prototype.listen=function () {
*/
document.getElementById('mid').onmousewheel = function (e) {
e.preventDefault();
var wheel = function (direct) {
var index=editor.core.floorIds.indexOf(editor.currentFloorId);
var toId = editor.currentFloorId;
@ -305,6 +304,7 @@ editor.constructor.prototype.listen=function () {
catch (ee) {
console.log(ee);
}
return false;
}
editor.preMapData = null;
@ -747,19 +747,7 @@ editor.constructor.prototype.listen=function () {
editor.preMapData = null;
reDo = null;
editor_mode.onmode('');
var now = editor.pos, last = editor.lastRightButtonPos[1];
if (now.x == last.x && now.y == last.y) return;
editor.pasteToPos(editor.lastCopyedInfo[1], now);
editor.pasteToPos(editor.lastCopyedInfo[0], last);
editor.updateMap();
editor.file.saveFloorFile(function (err) {
if (err) {
printe(err);
throw(err)
}
;printf('两位置的事件已互换');
editor.drawPosSelection();
});
editor.exchangePos(editor.pos, editor.lastRightButtonPos[1]);
}
var clearEvent = document.getElementById('clearEvent');

View File

@ -481,6 +481,8 @@ uievent.selectPoint = function (floorId, x, y, hideFloor, callback) {
uievent.updateSelectPoint = function (redraw) {
uievent.elements.title.innerText = '地图选点 ('+uievent.values.x+","+uievent.values.y+')';
if (redraw) {
core.setAlpha('uievent', 1);
core.clearMap('uievent');
core.drawThumbnail(uievent.values.floorId, null, null,
{ctx: 'uievent', centerX: uievent.values.left + core.__HALF_SIZE__,
centerY: uievent.values.top + core.__HALF_SIZE__});

View File

@ -225,6 +225,12 @@ var comment_c456ea59_6018_45ef_8bcc_211a24c627dc = {
"_range": "false",
"_data": "图块类别"
},
"name": {
"_leaf": true,
"_type": "textarea",
"_string": true,
"_data": "图块名称"
},
"trigger": {
"_leaf": true,
"_type": "select",

View File

@ -363,7 +363,8 @@ maps.prototype._getBgFgMapArray = function (name, floorId, noCache) {
return core.status[name + "maps"][floorId];
var arr = core.clone(core.floors[floorId][name + "map"] || []);
if (main.mode == 'editor') arr = core.clone(editor[name + "map"]) || arr;
if (main.mode == 'editor' && !(uievent && uievent.isOpen))
arr = core.clone(editor[name + "map"]) || arr;
for (var x = 0; x < width; x++) {
for (var y = 0; y < height; y++) {
arr[y] = arr[y] || [];
@ -1223,7 +1224,7 @@ maps.prototype.getBlockInfo = function (block) {
if (block == 0) return null;
block = this.initBlock(0, 0, block, true);
}
var number = block.id, id = block.event.id, cls = block.event.cls,
var number = block.id, id = block.event.id, cls = block.event.cls, name = block.event.name,
image = null, posX = 0, posY = 0, animate = block.event.animate,
height = block.event.height || 32, faceIds = {};
@ -1231,6 +1232,7 @@ maps.prototype.getBlockInfo = function (block) {
else if (id == 'airwall') {
if (!core.material.images.airwall) return null;
image = core.material.images.airwall;
name = "空气墙";
}
else if (cls == 'tileset') {
var offset = core.icons.getTilesetOffset(id);
@ -1246,9 +1248,12 @@ maps.prototype.getBlockInfo = function (block) {
image = core.material.images[cls];
posY = core.material.icons[cls][id];
faceIds = block.event.faceIds || {};
if (core.material.enemys[id]) {
name = core.material.enemys[id].name;
}
}
return {number: number, id: id, cls: cls, image: image, posX: posX, posY: posY, height: height, faceIds: faceIds, animate: animate};
return {number: number, id: id, cls: cls, name: name, image: image, posX: posX, posY: posY, height: height, faceIds: faceIds, animate: animate};
}
////// 搜索某个图块出现的所有位置 //////

View File

@ -535,7 +535,7 @@ ui.prototype._getTitleAndIcon = function (content) {
else {
var blockInfo = core.getBlockInfo(s4);
if (blockInfo != null) {
if (core.material.enemys[s4]) title = core.material.enemys[s4].name;
if (blockInfo.name) title = blockInfo.name;
image = blockInfo.image;
icon = blockInfo.posY;
height = blockInfo.height;
@ -544,7 +544,10 @@ ui.prototype._getTitleAndIcon = function (content) {
else title = s4;
}
}
if (s3) title = s3;
if (s3 != null) {
title = s3;
if (title == 'null') title = null;
}
return "";
});
return {