diff --git a/API列表.txt b/API列表.txt
index 71fa3a6b..2f846828 100644
--- a/API列表.txt
+++ b/API列表.txt
@@ -1342,6 +1342,12 @@ core.loadMap(data, floorId)
从data中读取楼层数据,并调用core.loadFloor()进行初始化。
+core.removeMaps(fromId, toId)
+删除某个区域的地图。调用此函数后,这些楼层将不可飞,不可被浏览地图,也不计入存档。
+fromId和toId为要删除的起终点楼层ID;toId也可以不填代表只删除某一层。
+此函数适用于高层塔的砍层,例如每100层一个区域且互相独立,不可再返回的情况。
+
+
core.resizeMap(floorId)
根据某层楼的地图大小来调整大地图的画布大小。floorId可为null表示当前层。
diff --git a/README.md b/README.md
index e4811ade..17ab6be6 100644
--- a/README.md
+++ b/README.md
@@ -64,6 +64,9 @@ HTML5 canvas制作的魔塔样板,支持全平台游戏!
* [x] 编辑器支持连续Ctrl+Z的撤销,Ctrl+Y的重做
* [x] 新增tileset右键绑定宽高,以替代贴图模式
* [x] 多重自动存档,可以连续A键读档
+* [x] 高层塔分区域支持
+* [x] 自绘状态栏点击事件
+* [x] 绘制的锁定模式
* [x] 等待用户操作增设分歧选项
* [x] 增设压缩模式,会对图片等进行zip压缩
* [x] 追加素材现在可以同时进行自动注册
diff --git a/_docs/api.md b/_docs/api.md
index 4e2125e3..4965d648 100644
--- a/_docs/api.md
+++ b/_docs/api.md
@@ -1341,6 +1341,12 @@ core.loadMap(data, floorId)
从data中读取楼层数据,并调用core.loadFloor()进行初始化。
+core.removeMaps(fromId, toId)
+删除某个区域的地图。调用此函数后,这些楼层将不可飞,不可被浏览地图,也不计入存档。
+fromId和toId为要删除的起终点楼层ID;toId也可以不填代表只删除某一层。
+此函数适用于高层塔的砍层,例如每100层一个区域且互相独立,不可再返回的情况。
+
+
core.resizeMap(floorId)
根据某层楼的地图大小来调整大地图的画布大小。floorId可为null表示当前层。
diff --git a/_server/editor.js b/_server/editor.js
index 525f8abe..8cec0a7d 100644
--- a/_server/editor.js
+++ b/_server/editor.js
@@ -55,6 +55,7 @@ function editor() {
lastUsedDiv: document.getElementById('lastUsedDiv'),
lastUsed: document.getElementById('lastUsed'),
lastUsedCtx: document.getElementById('lastUsed').getContext('2d'),
+ lockMode: document.getElementById('lockMode'),
};
this.uivalues={
@@ -98,6 +99,7 @@ function editor() {
// tile
tileSize: [1,1],
+ lockMode: false,
// 最近使用的图块
lastUsed: [],
@@ -405,20 +407,22 @@ editor.prototype.updateLastUsedMap = function () {
ctx.strokeStyle = 'rgba(255,128,0,0.85)';
ctx.lineWidth = 4;
for (var i = 0; i < editor.uivalues.lastUsed.length; ++i) {
- var x = i % core.__SIZE__, y = parseInt(i / core.__SIZE__);
- var info = editor.uivalues.lastUsed[i];
- if (!info || !info.images) continue;
- if (info.isTile) {
- ctx.drawImage(core.material.images.tilesets[info.images], 32 * info.x, 32 * info.y, 32, 32, x*32, y*32, 32, 32);
- } else if (info.images == 'autotile') {
- ctx.drawImage(core.material.images.autotile[info.id], 0, 0, 32, 32, x * 32, y * 32, 32, 32);
- } else {
- var per_height = info.images.endsWith('48') ? 48 : 32;
- ctx.drawImage(core.material.images[info.images], 0, info.y * per_height, 32, per_height, x * 32, y * 32, 32, 32);
- }
- if (selectBox.isSelected() && editor.info.id == info.id) {
- ctx.strokeRect(32 * x + 2, 32 * y + 2, 28, 28);
- }
+ try {
+ var x = i % core.__SIZE__, y = parseInt(i / core.__SIZE__);
+ var info = editor.uivalues.lastUsed[i];
+ if (!info || !info.images) continue;
+ if (info.isTile && core.material.images.tilesets[info.images]) {
+ ctx.drawImage(core.material.images.tilesets[info.images], 32 * info.x, 32 * info.y, 32, 32, x*32, y*32, 32, 32);
+ } else if (info.images == 'autotile' && core.material.images.autotile[info.id]) {
+ ctx.drawImage(core.material.images.autotile[info.id], 0, 0, 32, 32, x * 32, y * 32, 32, 32);
+ } else {
+ var per_height = info.images.endsWith('48') ? 48 : 32;
+ ctx.drawImage(core.material.images[info.images], 0, info.y * per_height, 32, per_height, x * 32, y * 32, 32, 32);
+ }
+ if (selectBox.isSelected() && editor.info.id == info.id) {
+ ctx.strokeRect(32 * x + 2, 32 * y + 2, 28, 28);
+ }
+ } catch (e) {}
}
}
diff --git a/_server/editor_listen.js b/_server/editor_listen.js
index e4668d9a..970111b7 100644
--- a/_server/editor_listen.js
+++ b/_server/editor_listen.js
@@ -35,6 +35,7 @@ editor_listen_wrapper = function (editor) {
editor.dom.clearLoc.onmousedown = editor.uifunctions.clearLoc_click
editor.dom.lastUsed.onmousedown = editor.uifunctions.lastUsed_click;
+ editor.dom.lockMode.onchange = editor.uifunctions.lockMode_onchange;
editor.dom.brushMod.onchange = editor.uifunctions.brushMod_onchange
if (editor.dom.brushMod2) editor.dom.brushMod2.onchange = editor.uifunctions.brushMod2_onchange;
diff --git a/_server/editor_mappanel.js b/_server/editor_mappanel.js
index c25f3e68..d4546c44 100644
--- a/_server/editor_mappanel.js
+++ b/_server/editor_mappanel.js
@@ -570,6 +570,16 @@ editor_mappanel_wrapper = function (editor) {
editor.clearPos(true);
}
+ /**
+ * editor.dom.lockMode.onchange
+ * 点击【】
+ */
+ editor.uifunctions.lockMode_onchange = function () {
+ tip.msgs[11] = String('锁定模式开启下将不再点击空白处自动保存,请谨慎操作。');
+ tip.whichShow(12);
+ editor.uivalues.lockMode = editor.dom.lockMode.checked;
+ }
+
/**
* editor.dom.brushMod.onchange
* 切换画笔模式
@@ -591,7 +601,10 @@ editor_mappanel_wrapper = function (editor) {
* 切换画笔模式
*/
editor.uifunctions.brushMod3_onchange = function () {
- alert("从V2.6.6开始,tileset贴图模式已被废弃。\n请右键额外素材,并输入所需要绘制的宽高,然后单击地图以绘制一个区域。");
+ if (!core.getLocalStorage('alertTileMode') &&
+ !confirm("从V2.6.6开始,tileset贴图模式已被废弃。\n请右键额外素材,并输入所需要绘制的宽高,然后单击地图以绘制一个区域。\n\n点取消将不再显示此提示。")) {
+ core.setLocalStorage('alertTileMode', true);
+ }
// tip.showHelp(5)
tip.isSelectedBlock(false)
tip.msgs[11] = String('tileset贴图模式下可以按选中tileset素材,并在地图上拖动来一次绘制一个区域');
diff --git a/_server/editor_ui.js b/_server/editor_ui.js
index ad37245e..cadd3b2f 100644
--- a/_server/editor_ui.js
+++ b/_server/editor_ui.js
@@ -48,7 +48,7 @@ editor_ui_wrapper = function (editor) {
break;
}
}
- if (unselect) {
+ if (unselect && !editor.uivalues.lockMode) {
if (clickpath.indexOf('eui') === -1 && clickpath.indexOf('lastUsed') === -1) {
if (selectBox.isSelected()) {
editor_mode.onmode('');
diff --git a/_server/table/functions.comment.js b/_server/table/functions.comment.js
index 6f30fa75..81e18e7c 100644
--- a/_server/table/functions.comment.js
+++ b/_server/table/functions.comment.js
@@ -139,6 +139,12 @@ var functions_comment_c456ea59_6018_45ef_8bcc_211a24c627dc = {
"_type": "textarea",
"_lint": true,
"_data": "按键处理"
+ },
+ "onStatusBarClick": {
+ "_leaf": true,
+ "_type": "textarea",
+ "_lint": true,
+ "_data": "状态栏点击事件,仅在开启自绘状态栏时生效"
}
}
},
diff --git a/editor-mobile.html b/editor-mobile.html
index 6b81757f..6946dedf 100644
--- a/editor-mobile.html
+++ b/editor-mobile.html
@@ -374,6 +374,7 @@
+ 锁定模式
+ 锁定模式
画线
diff --git a/libs/actions.js b/libs/actions.js
index 9f63d0bd..db190b0b 100644
--- a/libs/actions.js
+++ b/libs/actions.js
@@ -59,6 +59,8 @@ actions.prototype._init = function () {
// --- longClick注册
this.registerAction('longClick', '_sys_longClick_lockControl', this._sys_longClick_lockControl, 50);
this.registerAction('longClick', '_sys_longClick', this._sys_longClick, 0);
+ // --- onStatusBarClick注册
+ this.registerAction('onStatusBarClick', '_sys_onStatusBarClick', this._sys_onStatusBarClick, 0);
}
@@ -612,7 +614,7 @@ actions.prototype._getClickLoc = function (x, y) {
////// 具体点击屏幕上(x,y)点时,执行的操作 //////
actions.prototype.onclick = function (x, y, stepPostfix) {
// console.log("Click: (" + x + "," + y + ")");
- this.doRegisteredAction('onclick', x, y, stepPostfix || []);
+ return this.doRegisteredAction('onclick', x, y, stepPostfix || []);
}
actions.prototype._sys_onclick_lockControl = function (x, y) {
@@ -844,6 +846,19 @@ actions.prototype._sys_longClick = function (x, y, fromEvent) {
return false;
}
+actions.prototype.onStatusBarClick = function (e) {
+ if (!core.isPlaying()) return false;
+ var left = core.dom.gameGroup.offsetLeft + 3;
+ var top = core.dom.gameGroup.offsetTop + 3;
+ var px = parseInt((e.clientX - left) / core.domStyle.scale), py = parseInt((e.clientY - top) / core.domStyle.scale);
+ return this.doRegisteredAction('onStatusBarClick', px, py);
+}
+
+actions.prototype._sys_onStatusBarClick = function (px, py) {
+ if (this.actionsdata.onStatusBarClick)
+ return this.actionsdata.onStatusBarClick(px, py);
+}
+
/////////////////// 在某个界面时的按键点击效果 ///////////////////
// 数字键快速选择选项
diff --git a/libs/loader.js b/libs/loader.js
index 1804c82f..5231f8d8 100644
--- a/libs/loader.js
+++ b/libs/loader.js
@@ -207,9 +207,7 @@ loader.prototype._loadAnimates = function () {
core.loader._loadAnimate(t, animates[name]);
}
}
- }, null, true, function (percentage) {
- core.loader._setStartProgressVal(percentage * 100);
- });
+ }, null, true);
} else {
core.animates.forEach(function (t) {
core.http('GET', 'project/animates/' + t + ".animate?v=" + main.version, null, function (content) {
@@ -284,8 +282,6 @@ loader.prototype._loadMusic = function () {
core.loader._loadOneSound_decodeData(name, data[name]);
}
}
- }, null, false, function (percentage) {
- core.loader._setStartProgressVal(percentage * 100);
});
} else {
core.sounds.forEach(function (t) {
diff --git a/libs/maps.js b/libs/maps.js
index ea3a89a1..a5cb4ada 100644
--- a/libs/maps.js
+++ b/libs/maps.js
@@ -258,6 +258,11 @@ maps.prototype.saveMap = function (floorId) {
}
return map;
}
+ // 砍层状态:直接返回
+ if (main.mode == 'play' && (flags.__removed__ || []).indexOf(floorId) >= 0) {
+ return { canFlyTo: false, cannotViewMap: true };
+ }
+
var map = maps[floorId], floor = core.floors[floorId];
var blocks = this._getMapArrayFromBlocks(map.blocks, floor.width, floor.height, true);
if (main.mode == 'editor') return blocks;
@@ -293,6 +298,23 @@ maps.prototype.loadMap = function (data, floorId) {
return this.loadFloor(floorId, data[floorId]);
}
+////// 删除地图,不计入存档 //////
+maps.prototype.removeMaps = function (fromId, toId) {
+ if (!core.isPlaying()) return;
+ toId = toId || fromId;
+ var fromIndex = core.floorIds.indexOf(fromId),
+ toIndex = core.floorIds.indexOf(toId);
+ if (toIndex < 0) toIndex = core.floorIds.length - 1;
+ flags.__removed__ = flags.__removed__ || [];
+ for (var i = fromIndex; i <= toIndex; ++i) {
+ var floorId = core.floorIds[i];
+ delete flags.__visited__[floorId];
+ flags.__removed__.push(floorId);
+ core.status.maps[floorId].canFlyTo = false;
+ core.status.maps[floorId].cannotViewMap = true;
+ }
+}
+
////// 更改地图画布的尺寸
maps.prototype.resizeMap = function (floorId) {
floorId = floorId || core.status.floorId;
diff --git a/main.js b/main.js
index 8f581d72..d9e3534a 100644
--- a/main.js
+++ b/main.js
@@ -518,6 +518,15 @@ main.dom.data.ontouchend = function (e) {
}
}
+main.dom.statusCanvas.onclick = function (e) {
+ try {
+ e.preventDefault();
+ main.core.onStatusBarClick(e);
+ } catch (e) {
+ main.log(e);
+ }
+}
+
////// 点击状态栏中的怪物手册时 //////
main.statusBar.image.book.onclick = function (e) {
e.stopPropagation();
diff --git a/project/functions.js b/project/functions.js
index e094e708..c771bb60 100644
--- a/project/functions.js
+++ b/project/functions.js
@@ -933,6 +933,23 @@ var functions_d6ad677b_427a_4623_b50f_a445a3b0ef8a =
*/
}
+},
+ "onStatusBarClick": function (px, py) {
+ // 点击状态栏时触发的事件,仅在自绘状态栏开启时生效
+ // px和py为点击的像素坐标
+ //
+ // 横屏模式下状态栏的画布大小是 129*416
+ // 竖屏模式下状态栏的画布大小是 416*(32*rows+9) 其中rows为状态栏行数,即全塔属性中statusCanvasRowsOnMobile值
+ // 可以使用 core.domStyle.isVertical 来判定当前是否是竖屏模式
+
+ // 如果正在执行事件,则忽略
+ if (core.status.lockControl) return;
+ // 如果当前正在行走,则忽略;也可以使用 core.waitHeroToStop(callback) 来停止行走再回调执行脚本
+ if (core.isMoving()) return;
+
+ // 判定px和py来执行自己的脚本内容.... 注意横竖屏
+ // 这里是直接打出点击坐标的例子。
+ // console.log("onStatusBarClick:", px, py);
}
},
"control": {
diff --git a/更新说明.txt b/更新说明.txt
index ab268191..1cd892d5 100644
--- a/更新说明.txt
+++ b/更新说明.txt
@@ -5,6 +5,9 @@
编辑器支持连续Ctrl+Z的撤销,Ctrl+Y的重做
新增tileset右键绑定宽高,以替代贴图模式
多重自动存档,可以连续A键读档
+高层塔分区域支持
+自绘状态栏点击事件
+绘制的锁定模式
等待用户操作增设分歧选项
增设压缩模式,会对图片等进行zip压缩
追加素材现在可以同时进行自动注册