This commit is contained in:
ckcz123 2019-11-30 11:47:58 +08:00
parent 00d204de2a
commit ca69ca5005
7 changed files with 58 additions and 12 deletions

View File

@ -608,6 +608,16 @@ editor.prototype.addUsedFlags = function (s) {
s.replace(/flag:([a-zA-Z0-9_\u4E00-\u9FCC]+)/g, function (s0, s1) {
editor.used_flags[s1] = true; return s0;
});
s.replace(/flags\.([a-zA-Z_]\w*)/g, function (s0, s1) {
editor.used_flags[s1] = true; return s0;
});
if (window.flags) {
for (var s in editor.used_flags) {
if (!(s in window.flags)) {
window.flags[s] = null;
}
}
}
}
editor.prototype.listen = function () {

View File

@ -687,7 +687,7 @@ function omitedcheckUpdateFunction(event) {
var previewBlock = function (b) {
var types = [
"previewUI_s", "clearMap_s", "clearMap_1_s", "setAttribute_s", "fillText_s",
"fillBoldText_s", "drawTextContent_s", "fillRect_s", "strokeRect_s", "drawLine_s",
"fillBoldText_s", "fillRect_s", "strokeRect_s", "drawLine_s",
"drawArrow_s", "fillPolygon_s", "strokePolygon_s", "fillCircle_s", "strokeCircle_s",
"drawImage_s", "drawImage_1_s", "drawIcon_s", "drawBackground_s", "drawSelector_s", "drawSelector_1_s"
];
@ -965,6 +965,16 @@ function omitedcheckUpdateFunction(event) {
}
}
// 提供 flags.xxx 补全
index = content.lastIndexOf("flags.");
if (index >= 0) {
var token = content.substring(index+6);
return Object.keys(editor.used_flags || {}).filter(function (one) {
return one != token && one.startsWith(token)
&& /^[a-zA-Z_]\w*$/.test(one);
}).sort();
}
return [];
}

View File

@ -146,11 +146,15 @@ editor_file = function (editor, callback) {
var templateActions = [];
var image = info.images;
var bindFaceIds = false;
if (image=='autotile') {
callback('不能对自动元件进行自动注册!');
return;
}
if (image=='npc48' && confirm("你想绑定npc48的朝向么\n如果是则会连续四个一组的对npc48的faceIds进行自动绑定。")) {
bindFaceIds = true;
}
var c=image.toUpperCase().charAt(0);
// terrains id
@ -162,15 +166,20 @@ editor_file = function (editor, callback) {
var allIds = [];
editor.ids.forEach(function (v) {
if (v.images==image) {
allIds[v.y]=true;
allIds[v.y]=v;
}
})
var per_height = image.endsWith('48')?48:32;
var faceIds = []; // down, left, right, up
var idnum=300;
for (var y=0; y<editor.widthsX[image][3]/per_height;y++) {
if (allIds[y]) continue;
if (allIds[y] != null) {
faceIds.push(allIds[y]);
continue;
}
while (editor.core.maps.blocksInfo[idnum]) idnum++;
// get id num
@ -182,7 +191,8 @@ editor_file = function (editor, callback) {
else {
iconActions.push(["add", "['" + image + "']['" + id + "']", y])
}
mapActions.push(["add", "['" + idnum + "']", {'cls': image, 'id': id}])
mapActions.push(["add", "['" + idnum + "']", {'cls': image, 'id': id}]);
faceIds.push({idnum: idnum, id: id});
if (image=='items')
templateActions.push(["add", "['items']['" + id + "']", editor.file.comment._data.items_template]);
else if (image.indexOf('enemy')==0)
@ -190,6 +200,17 @@ editor_file = function (editor, callback) {
idnum++;
}
if (bindFaceIds) {
for (var i = 0; i < faceIds.length - 3; i+=4) {
var down = faceIds[i], left = faceIds[i+1], right = faceIds[i+2], up = faceIds[i+3];
var obj = {down: down.id, left: left.id, right: right.id, up: up.id};
mapActions.push(["add", "['" + down.idnum + "']['faceIds']", obj]);
mapActions.push(["add", "['" + left.idnum + "']['faceIds']", obj]);
mapActions.push(["add", "['" + right.idnum + "']['faceIds']", obj]);
mapActions.push(["add", "['" + up.idnum + "']['faceIds']", obj]);
}
}
if (mapActions.length==0) {
callback("没有要注册的项!");
return;

View File

@ -234,7 +234,14 @@ events.prototype._gameOver_askRate = function (ending) {
}
if (ending == null) {
core.restart();
core.status.event.selection = 0;
core.ui.drawConfirmBox("你想读取自动存档么?", function () {
core.ui.closePanel();
core.doSL("autoSave", "load");
}, function () {
core.ui.closePanel();
core.restart();
});
return;
}

View File

@ -138,8 +138,7 @@ var icons_4665ee12_3a1f_44a4_bea3_0fccba634dc1 =
"npc0": 0,
"npc1": 1,
"npc2": 2,
"npc3": 3,
"npc4": 4
"npc3": 3
},
"enemys": {
"greenSlime": 0,

BIN
project/images/npc48.png Normal file → Executable file

Binary file not shown.

Before

Width:  |  Height:  |  Size: 9.3 KiB

After

Width:  |  Height:  |  Size: 5.4 KiB

View File

@ -98,11 +98,10 @@ var maps_90f36752_8815_4be8_b32b_d7fad1d0542e =
"130": {"cls":"npcs","id":"pinkShop"},
"131": {"cls":"npcs","id":"blueShop"},
"132": {"cls":"npcs","id":"princess"},
"133": {"cls":"npc48","id":"npc0"},
"134": {"cls":"npc48","id":"npc1"},
"135": {"cls":"npc48","id":"npc2"},
"136": {"cls":"npc48","id":"npc3"},
"137": {"cls":"npc48","id":"npc4"},
"133": {"cls":"npc48","id":"npc0","faceIds":{"down":"npc0","left":"npc1","right":"npc2","up":"npc3"}},
"134": {"cls":"npc48","id":"npc1","faceIds":{"down":"npc0","left":"npc1","right":"npc2","up":"npc3"}},
"135": {"cls":"npc48","id":"npc2","faceIds":{"down":"npc0","left":"npc1","right":"npc2","up":"npc3"}},
"136": {"cls":"npc48","id":"npc3","faceIds":{"down":"npc0","left":"npc1","right":"npc2","up":"npc3"}},
"151": {"cls":"autotile","id":"autotile1","noPass":true},
"152": {"cls":"autotile","id":"autotile2","noPass":true},
"153": {"cls":"autotile","id":"autotile3","noPass":true},