Merge pull request #439 from ckcz123/v2.x

V2.x
This commit is contained in:
Zhang Chen 2020-01-13 13:10:24 +08:00 committed by GitHub
commit 556c893bda
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
16 changed files with 125 additions and 22 deletions

View File

@ -1342,6 +1342,12 @@ core.loadMap(data, floorId)
从data中读取楼层数据并调用core.loadFloor()进行初始化。
core.removeMaps(fromId, toId)
删除某个区域的地图。调用此函数后,这些楼层将不可飞,不可被浏览地图,也不计入存档。
fromId和toId为要删除的起终点楼层IDtoId也可以不填代表只删除某一层。
此函数适用于高层塔的砍层例如每100层一个区域且互相独立不可再返回的情况。
core.resizeMap(floorId)
根据某层楼的地图大小来调整大地图的画布大小。floorId可为null表示当前层。

View File

@ -64,6 +64,9 @@ HTML5 canvas制作的魔塔样板支持全平台游戏
* [x] 编辑器支持连续Ctrl+Z的撤销Ctrl+Y的重做
* [x] 新增tileset右键绑定宽高以替代贴图模式
* [x] 多重自动存档可以连续A键读档
* [x] 高层塔分区域支持
* [x] 自绘状态栏点击事件
* [x] 绘制的锁定模式
* [x] 等待用户操作增设分歧选项
* [x] 增设压缩模式会对图片等进行zip压缩
* [x] 追加素材现在可以同时进行自动注册

View File

@ -1341,6 +1341,12 @@ core.loadMap(data, floorId)
从data中读取楼层数据并调用core.loadFloor()进行初始化。
core.removeMaps(fromId, toId)
删除某个区域的地图。调用此函数后,这些楼层将不可飞,不可被浏览地图,也不计入存档。
fromId和toId为要删除的起终点楼层IDtoId也可以不填代表只删除某一层。
此函数适用于高层塔的砍层例如每100层一个区域且互相独立不可再返回的情况。
core.resizeMap(floorId)
根据某层楼的地图大小来调整大地图的画布大小。floorId可为null表示当前层。

View File

@ -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) {}
}
}

View File

@ -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;

View File

@ -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素材并在地图上拖动来一次绘制一个区域');

View File

@ -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('');

View File

@ -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": "状态栏点击事件,仅在开启自绘状态栏时生效"
}
}
},

View File

@ -374,6 +374,7 @@
<option value="commonevent">公共事件</option>
<option value="plugins">插件编写</option>
</select>
<span style="font-size: 12px"><input type="checkbox" id="lockMode"/>锁定模式</span>
<select id="brushMod" style="clear:right">
<option value="line">画线</option>
<option value="rectangle">画矩形</option>

View File

@ -333,6 +333,7 @@
<option value="commonevent">公共事件</option>
<option value="plugins">插件编写</option>
</select>
<span style="font-size: 12px"><input type="checkbox" id="lockMode"/>锁定模式</span>
<br/>
<span style="font-size: 12px;">
<input type="radio" id="brushMod" name="brushMod" value="line" checked="checked" />画线

View File

@ -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);
}
/////////////////// 在某个界面时的按键点击效果 ///////////////////
// 数字键快速选择选项

View File

@ -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) {

View File

@ -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;

View File

@ -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();

View File

@ -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": {

View File

@ -5,6 +5,9 @@
编辑器支持连续Ctrl+Z的撤销Ctrl+Y的重做
新增tileset右键绑定宽高以替代贴图模式
多重自动存档可以连续A键读档
高层塔分区域支持
自绘状态栏点击事件
绘制的锁定模式
等待用户操作增设分歧选项
增设压缩模式会对图片等进行zip压缩
追加素材现在可以同时进行自动注册