Merge pull request #387 from ckcz123/v2.x

V2.x
This commit is contained in:
Zhang Chen 2019-07-24 18:23:30 +08:00 committed by GitHub
commit 6564448df5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
22 changed files with 375 additions and 93 deletions

View File

@ -56,7 +56,6 @@ core.platform.isPC (是否是电脑端)
core.platform.isAndroid (是否是安卓端)
core.platform.isIOS 是否是iOS端
core.platform.useLocalForage (是否开启了新版存档)
core.platform.extendKeyBoard (是否开启了拓展键盘)
core.domStyle

View File

@ -55,17 +55,18 @@ HTML5 canvas制作的魔塔样板支持全平台游戏
## 更新说明
### 2019.7.5 V2.6.3
### 2019.7.24 V2.6.3
* [x] 标题界面大幅美化,支持键盘开始游戏
* [x] 标题界面大幅美化,增加闪烁光标,支持键盘开始游戏
* [x] 事件编辑器支持自动补全能对flag和API列表等进行补全
* [x] 剧情文本中\\c修改字体大小\\d和\\e切换粗体和斜体
* [x] 可以指定每个选择项的出现条件,动态生成
* [x] 事件:设置视角&移动视角
* [x] 可以指定显示选择项的出现条件并动态生成
* [x] 楼层传送器的平面传送模式(哪里离开飞回到哪里)
* [x] UI绘制事件增添绘制圆边框且可直接双击预览
* [x] UI绘制事件增添绘制圆和绘制圆边框
* [x] 所有的UI绘制事件均可以双击预览
* [x] 播放BGM事件可以一直持续播放直到下次调用
* [x] \f立绘支持alpha值
* [x] 只有一个全局商店时V键能直接打开
* [x] 支持在脚本编辑中直接flags.xxx调用自定义变量
* [x] 首次获得道具将给予提示
* [x] 等待用户操作支持滚轮视为PgUp和PgDn

View File

@ -57,7 +57,6 @@ core.platform.isPC (是否是电脑端)
core.platform.isAndroid (是否是安卓端)
core.platform.isIOS 是否是iOS端
core.platform.useLocalForage (是否开启了新版存档)
core.platform.extendKeyBoard (是否开启了拓展键盘)
core.domStyle

View File

@ -293,6 +293,8 @@ action
| changeFloor_s
| changePos_0_s
| changePos_1_s
| setViewport_s
| moveViewport_s
| useItem_s
| openShop_s
| disableShop_s
@ -756,7 +758,7 @@ return code;
*/;
setBlock_s
: '转变图块为' EvalString 'x' PosString? ',' 'y' PosString? '楼层' IdString? Newline
: '转变图块为' EvalString 'x' EvalString? ',' 'y' EvalString? '楼层' IdString? Newline
/* setBlock_s
@ -765,8 +767,21 @@ helpUrl : https://h5mota.com/games/template/_docs/#/event?id=setblock%EF%BC%9A%E
colour : this.mapColor
default : ["yellowDoor","","",""]
var floorstr = '';
if (PosString_0 && PosString_1) {
floorstr = ', "loc": ['+PosString_0+','+PosString_1+']';
if (EvalString_1 && EvalString_2) {
var pattern1 = MotaActionFunctions.pattern.id;
if(pattern1.test(EvalString_1) || pattern1.test(EvalString_2)){
EvalString_1=MotaActionFunctions.PosString_pre(EvalString_1);
EvalString_2=MotaActionFunctions.PosString_pre(EvalString_2);
EvalString_1=[EvalString_1,EvalString_2]
} else {
var pattern2 = /^([+-]?\d+)(,[+-]?\d+)*$/;
if(!pattern2.test(EvalString_1) || !pattern2.test(EvalString_2))throw new Error('坐标格式错误,请右键点击帮助查看格式');
EvalString_1=EvalString_1.split(',');
EvalString_2=EvalString_2.split(',');
if(EvalString_1.length!==EvalString_2.length)throw new Error('坐标格式错误,请右键点击帮助查看格式');
for(var ii=0;ii<EvalString_1.length;ii++)EvalString_1[ii]='['+EvalString_1[ii]+','+EvalString_2[ii]+']';
}
floorstr = ', "loc": ['+EvalString_1.join(',')+']';
}
IdString_0 = IdString_0 && (', "floorId": "'+IdString_0+'"');
var code = '{"type": "setBlock", "number": "'+EvalString_0+'"'+floorstr+IdString_0+'},\n';
@ -898,7 +913,7 @@ return code;
*/;
setBgFgBlock_s
: '转变图层块' Bg_Fg_List '为' EvalString 'x' PosString? ',' 'y' PosString? '楼层' IdString? Newline
: '转变图层块' Bg_Fg_List '为' EvalString 'x' EvalString? ',' 'y' EvalString? '楼层' IdString? Newline
/* setBgFgBlock_s
@ -907,8 +922,21 @@ helpUrl : https://h5mota.com/games/template/_docs/#/event?id=setblock%EF%BC%9A%E
colour : this.mapColor
default : ["bg","yellowDoor","","",""]
var floorstr = '';
if (PosString_0 && PosString_1) {
floorstr = ', "loc": ['+PosString_0+','+PosString_1+']';
if (EvalString_1 && EvalString_2) {
var pattern1 = MotaActionFunctions.pattern.id;
if(pattern1.test(EvalString_1) || pattern1.test(EvalString_2)){
EvalString_1=MotaActionFunctions.PosString_pre(EvalString_1);
EvalString_2=MotaActionFunctions.PosString_pre(EvalString_2);
EvalString_1=[EvalString_1,EvalString_2]
} else {
var pattern2 = /^([+-]?\d+)(,[+-]?\d+)*$/;
if(!pattern2.test(EvalString_1) || !pattern2.test(EvalString_2))throw new Error('坐标格式错误,请右键点击帮助查看格式');
EvalString_1=EvalString_1.split(',');
EvalString_2=EvalString_2.split(',');
if(EvalString_1.length!==EvalString_2.length)throw new Error('坐标格式错误,请右键点击帮助查看格式');
for(var ii=0;ii<EvalString_1.length;ii++)EvalString_1[ii]='['+EvalString_1[ii]+','+EvalString_2[ii]+']';
}
floorstr = ', "loc": ['+EvalString_1.join(',')+']';
}
IdString_0 = IdString_0 && (', "floorId": "'+IdString_0+'"');
var code = '{"type": "setBgFgBlock", "name": "' + Bg_Fg_List_0 + '", "number": "'+EvalString_0+'"'+floorstr+IdString_0+'},\n';
@ -1215,6 +1243,38 @@ var code = '{"type": "animate", "name": "'+IdString_0+'"'+EvalString_0+async+'},
return code;
*/;
setViewport_s
: '设置视角' '左上角坐标' 'x' PosString? ',' 'y' PosString? Newline
/* setViewport_s
tooltip : setViewport: 设置视角
helpUrl : https://h5mota.com/games/template/_docs/#/event?id=changepos%EF%BC%9A%E5%BD%93%E5%89%8D%E4%BD%8D%E7%BD%AE%E5%88%87%E6%8D%A2%E5%8B%87%E5%A3%AB%E8%BD%AC%E5%90%91
default : ["",""]
colour : this.soundColor
var loc = '';
if (PosString_0 && PosString_1) {
loc = ', "loc": ['+PosString_0+','+PosString_1+']';
}
var code = '{"type": "setViewport"'+loc+'},\n';
return code;
*/;
moveViewport_s
: '移动视角' '动画时间' Int? '不等待执行完毕' Bool BGNL? StepString Newline
/* moveViewport_s
tooltip : moveViewport移动视角
helpUrl : https://h5mota.com/games/template/_docs/#/event?id=movehero%EF%BC%9A%E7%A7%BB%E5%8A%A8%E5%8B%87%E5%A3%AB
default : [300,false,"上右3下2左"]
colour : this.soundColor
Int_0 = Int_0!=='' ?(', "time": '+Int_0):'';
Bool_0 = Bool_0?', "async": true':'';
var code = '{"type": "moveViewport"'+Int_0+Bool_0+', "steps": '+JSON.stringify(StepString_0)+'},\n';
return code;
*/;
showImage_s
: '显示图片' '图片编号' Int '图片' EvalString BGNL?
'绘制的起点像素' 'x' PosString 'y' PosString '不透明度' Number '时间' Int '不等待执行完毕' Bool Newline
@ -2846,9 +2906,16 @@ ActionParser.prototype.parseAction = function() {
x_str.join(','),y_str.join(','),data.floorId||'',data.time||0,data.async||false,this.next]);
break;
case "setBlock": // 设置图块
data.loc=data.loc||['',''];
data.loc=data.loc||[];
if (!(data.loc[0] instanceof Array))
data.loc = [data.loc];
var x_str=[],y_str=[];
data.loc.forEach(function (t) {
x_str.push(t[0]);
y_str.push(t[1]);
})
this.next = MotaActionBlocks['setBlock_s'].xmlText([
data.number||0,data.loc[0],data.loc[1],data.floorId||'',this.next]);
data.number||0,x_str.join(','),y_str.join(','),data.floorId||'',this.next]);
break;
case "showFloorImg": // 显示贴图
data.loc=data.loc||[];
@ -2899,9 +2966,16 @@ ActionParser.prototype.parseAction = function() {
data.name||'bg', x_str.join(','),y_str.join(','),data.floorId||'',this.next]);
break;
case "setBgFgBlock": // 设置图块
data.loc=data.loc||['',''];
data.loc=data.loc||[];
if (!(data.loc[0] instanceof Array))
data.loc = [data.loc];
var x_str=[],y_str=[];
data.loc.forEach(function (t) {
x_str.push(t[0]);
y_str.push(t[1]);
})
this.next = MotaActionBlocks['setBgFgBlock_s'].xmlText([
data.name||"bg", data.number||0,data.loc[0],data.loc[1],data.floorId||'',this.next]);
data.name||'bg', data.number||0, x_str.join(','),y_str.join(','),data.floorId||'',this.next]);
break;
case "setHeroIcon": // 改变勇士
this.next = MotaActionBlocks['setHeroIcon_s'].xmlText([
@ -2953,6 +3027,15 @@ ActionParser.prototype.parseAction = function() {
this.next = MotaActionBlocks['animate_s'].xmlText([
data.name,animate_loc,data.async||false,this.next]);
break;
case "setViewport": // 设置视角
data.loc = data.loc||['',''];
this.next = MotaActionBlocks['setViewport_s'].xmlText([
data.loc[0],data.loc[1],this.next]);
break;
case "moveViewport": // 移动视角
this.next = MotaActionBlocks['moveViewport_s'].xmlText([
data.time||0,data.async||false,this.StepString(data.steps),this.next]);
break;
case "vibrate": // 画面震动
this.next = MotaActionBlocks['vibrate_s'].xmlText([data.time||0, data.async||false, this.next]);
break;
@ -3507,7 +3590,7 @@ MotaActionFunctions.IdString_pre = function(IdString){
MotaActionFunctions.PosString_pre = function(PosString){
if (!PosString || /^-?\d+$/.test(PosString)) return PosString;
if (!(MotaActionFunctions.pattern.id.test(PosString)))throw new Error(PosString+'中包含了0-9 a-z A-Z _ 和中文之外的字符,或者是没有以flag: 开头');
//if (!(MotaActionFunctions.pattern.id.test(PosString)))throw new Error(PosString+'中包含了0-9 a-z A-Z _ 和中文之外的字符,或者是没有以flag: 开头');
return '"'+PosString+'"';
}

View File

@ -556,6 +556,42 @@ editor.prototype.exchangePos = function (startPos, endPos, callback) {
});
}
editor.prototype.moveBgFg = function (startPos, endPos, name, callback) {
if (!startPos || !endPos || ["bgmap","fgmap"].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.prototype.exchangeBgFg = function (startPos, endPos, name, callback) {
if (!startPos || !endPos || ["bgmap","fgmap"].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.prototype.clearPos = function (clearPos, pos, callback) {
var fields = Object.keys(editor.file.comment._data.floors._data.loc._data);
pos = pos || editor.pos;

View File

@ -150,6 +150,8 @@ editor_blockly = function () {
MotaActionBlocks['waitAsync_s'].xmlText(),
MotaActionBlocks['vibrate_s'].xmlText(),
MotaActionBlocks['animate_s'].xmlText(),
MotaActionBlocks['setViewport_s'].xmlText(),
MotaActionBlocks['moveViewport_s'].xmlText(),
MotaActionBlocks['showStatusBar_s'].xmlText(),
MotaActionBlocks['hideStatusBar_s'].xmlText(),
MotaActionBlocks['setCurtain_0_s'].xmlText(),
@ -760,7 +762,7 @@ function omitedcheckUpdateFunction(event) {
"closeDoor_s": ["PosString_0", "PosString_1"],
"show_s": ["EvalString_0", "EvalString_1", "IdString_0"],
"hide_s": ["EvalString_0", "EvalString_1", "IdString_0"],
"setBlock_s": ["PosString_0", "PosString_1", "IdString_0"],
"setBlock_s": ["EvalString_1", "EvalString_2", "IdString_0"],
"move_s": ["PosString_0", "PosString_1"],
"jump_s": ["PosString_2", "PosString_3"], // 跳跃暂时只考虑终点
"showBgFgMap_s": ["EvalString_0", "EvalString_1", "IdString_0"],
@ -769,7 +771,9 @@ function omitedcheckUpdateFunction(event) {
"showFloorImg_s": ["EvalString_0", "EvalString_1", "IdString_0"],
"hideFloorImg_s": ["EvalString_0", "EvalString_1", "IdString_0"],
"trigger_s": ["PosString_0", "PosString_1"],
"insert_2_s": ["PosString_0", "PosString_1", "IdString_0"]
"insert_2_s": ["PosString_0", "PosString_1", "IdString_0"],
"animate_s": ["EvalString_0", "EvalString_0"],
"setViewport_s": ["PosString_0", "PosString_1"]
}
editor_blockly.selectPoint = function () {
@ -778,6 +782,10 @@ function omitedcheckUpdateFunction(event) {
if (block != null && block.type in selectPointBlocks) {
arr = selectPointBlocks[block.type];
var xv = parseInt(block.getFieldValue(arr[0])), yv = parseInt(block.getFieldValue(arr[1]));
if (block.type == 'animate_s') {
var v = block.getFieldValue(arr[0]).split(",");
xv = parseInt(v[0]); yv = parseInt(v[1]);
}
if (!isNaN(xv)) x = xv;
if (!isNaN(yv)) y = yv;
if (arr[2] != null) floorId = block.getFieldValue(arr[2]) || floorId;
@ -788,8 +796,13 @@ function omitedcheckUpdateFunction(event) {
if (fv != editor.currentFloorId) block.setFieldValue(fv, arr[2]);
else block.setFieldValue(arr[3] ? fv : "", arr[2]);
}
block.setFieldValue(xv+"", arr[0]);
block.setFieldValue(yv+"", arr[1]);
if (block.type == 'animate_s') {
block.setFieldValue(xv+","+yv, arr[0]);
}
else {
block.setFieldValue(xv+"", arr[0]);
block.setFieldValue(yv+"", arr[1]);
}
if (block.type == 'changeFloor_m') {
block.setFieldValue("floorId", "Floor_List_0");
block.setFieldValue("loc", "Stair_List_0");
@ -935,6 +948,17 @@ Blockly.FieldTextInput.prototype.showInlineEditor_ = function(quietInput) {
}
}
else {
htmlInput.onkeydown = function (e) {
if (e.keyCode == 13 && awesomplete.opened && awesomplete.selected) {
e.stopPropagation();
e.stopImmediatePropagation();
e.preventDefault();
awesomplete.select();
return false;
}
}
// --- awesomplete
var awesomplete = new Awesomplete(htmlInput, {
minChars: 4,

View File

@ -209,7 +209,10 @@ editor.constructor.prototype.listen=function () {
if (!selectBox.isSelected()) {
//tip.whichShow(1);
// editor.movePos(startPos, endPos);
editor.exchangePos(startPos, endPos);
if (editor.layerMod == 'map')
editor.exchangePos(startPos, endPos);
else
editor.exchangeBgFg(startPos, endPos, editor.layerMod);
startPos = endPos = null;
uc.clearRect(0, 0, core.__PIXELS__, core.__PIXELS__);
return false;
@ -779,7 +782,10 @@ editor.constructor.prototype.listen=function () {
var brushMod3=document.getElementById('brushMod3');
if(brushMod3) {
brushMod3.onchange=function(){
tip.showHelp(5)
// tip.showHelp(5)
tip.isSelectedBlock(false)
tip.msgs[11] = String('tileset贴图模式下可以按选中tileset素材并在地图上拖动来一次绘制一个区域');
tip.whichShow(12);
editor.brushMod=brushMod3.value;
}
}

View File

@ -496,7 +496,7 @@ uievent.setPoint = function (floorId, x, y) {
uievent.values.floorId = floorId;
uievent.elements.selectFloor.value = floorId;
uievent.values.x = x != null ? x : ( uievent.values.x || 0);
uievent.values.y = y != null ? y : ( uievent.values.x || 0);
uievent.values.y = y != null ? y : ( uievent.values.y || 0);
uievent.values.width = core.floors[uievent.values.floorId].width || core.__SIZE__;
uievent.values.height = core.floors[uievent.values.floorId].height || core.__SIZE__;
uievent.values.left = core.clamp(uievent.values.x - core.__HALF_SIZE__, 0, uievent.values.width - core.__SIZE__);

View File

@ -554,11 +554,17 @@ var data_comment_c456ea59_6018_45ef_8bcc_211a24c627dc = {
"_data": "如果此项为true则视为钥匙盒红黄蓝钥匙+1若为false则视为大黄门钥匙"
},
"steelDoorWithoutKey": {
"_left": true,
"_leaf": true,
"_type": "checkbox",
"_bool": "bool",
"_data": "铁门是否不需要钥匙开启。如果此项为true则无需钥匙也可以开铁门。"
},
"itemFirstText": {
"_leaf": true,
"_type": "checkbox",
"_bool": "bool",
"_data": "首次获得道具是否提示"
},
"equipment": {
"_leaf": true,
"_type": "checkbox",

View File

@ -515,6 +515,7 @@
<canvas class='gameCanvas' id='curtain' width='416' height='416'></canvas>
<canvas class='gameCanvas' id='ui' width='416' height='416'></canvas>
<canvas class='gameCanvas' id='data' width='416' height='416'>此浏览器不支持HTML5</canvas>
<div id="next"></div>
</div>
</div>
<div id='inputDiv' style='display: none'>

View File

@ -498,6 +498,7 @@
<canvas class='gameCanvas' id='curtain' width='416' height='416'></canvas>
<canvas class='gameCanvas' id='ui' width='416' height='416'></canvas>
<canvas class='gameCanvas' id='data' width='416' height='416'>此浏览器不支持HTML5</canvas>
<div id="next"></div>
</div>
</div>
<div id='inputDiv' style='display: none'>

View File

@ -147,6 +147,7 @@
<canvas class='gameCanvas' id='curtain' width='416' height='416'></canvas>
<canvas class='gameCanvas' id='ui' width='416' height='416'></canvas>
<canvas class='gameCanvas' id='data' width='416' height='416'>此浏览器不支持HTML5</canvas>
<div id="next"></div>
</div>
</div>
<div id='inputDiv'>

View File

@ -137,7 +137,7 @@ actions.prototype._sys_onkeyDown = function (e) {
return;
}
}
e.preventDefault();
if (e.preventDefault) e.preventDefault();
core.status.holdingKeys.push(e.keyCode);
this.pressKey(e.keyCode);
} else {
@ -199,7 +199,7 @@ actions.prototype._sys_onkeyUp = function (e) {
break;
}
}
e.preventDefault();
if (e.preventDefault) e.preventDefault();
this.keyUp(e.keyCode, e.altKey);
} else {
if (e.keyCode == 17) core.status.ctrlDown = false;
@ -1934,8 +1934,6 @@ actions.prototype._clickSwitchs = function (x, y) {
case 7:
return this._clickSwitchs_clickMove();
case 8:
return this._clickSwitchs_ExtendKeyboard();
case 9:
core.status.event.selection = 0;
core.ui.drawSettings();
break;
@ -2000,13 +1998,6 @@ actions.prototype._clickSwitchs_clickMove = function () {
core.ui.drawSwitchs();
}
actions.prototype._clickSwitchs_ExtendKeyboard = function () {
core.platform.extendKeyboard = !core.platform.extendKeyboard;
core.setLocalStorage('extendKeyboard', core.platform.extendKeyboard);
core.updateStatusBar();
core.ui.drawSwitchs();
}
////// 系统设置界面时,放开某个键的操作 //////
actions.prototype._keyUpSwitchs = function (keycode) {
if (keycode == 27 || keycode == 88) {

View File

@ -19,7 +19,6 @@ control.prototype._init = function () {
this.registerAnimationFrame("totalTime", false, this._animationFrame_totalTime);
this.registerAnimationFrame("autoSave", true, this._animationFrame_autoSave);
this.registerAnimationFrame("globalAnimate", true, this._animationFrame_globalAnimate);
this.registerAnimationFrame("selector", false, this._animationFrame_selector);
this.registerAnimationFrame("animate", true, this._animationFrame_animate);
this.registerAnimationFrame("heroMoving", true, this._animationFrame_heroMoving);
this.registerAnimationFrame("weather", true, this._animationFrame_weather);
@ -151,23 +150,6 @@ control.prototype._animationFrame_globalAnimate = function (timestamp) {
core.animateFrame.globalTime = timestamp;
}
control.prototype._animationFrame_selector = function (timestamp) {
if (timestamp - core.animateFrame.selectorTime <= 20) return;
var opacity = null;
if (core.dymCanvas._selector) opacity = parseFloat(core.dymCanvas._selector.canvas.style.opacity);
else if (core.dymCanvas._uievent_selector) opacity = parseFloat(core.dymCanvas._uievent_selector.canvas.style.opacity);
if (!core.isset(opacity)) return;
if (core.animateFrame.selectorUp)
opacity += 0.02;
else
opacity -= 0.02;
if (opacity > 0.95 || opacity < 0.55)
core.animateFrame.selectorUp = !core.animateFrame.selectorUp;
core.setOpacity("_selector", opacity);
core.setOpacity("_uievent_selector", opacity);
core.animateFrame.selectorTime = timestamp;
}
control.prototype._animationFrame_animate = function (timestamp) {
if (timestamp - core.animateFrame.animateTime < 50 || !core.status.animateObjs || core.status.animateObjs.length == 0) return;
core.clearMap('animate');
@ -797,6 +779,7 @@ control.prototype.drawHero = function (status, offset) {
});
core.control.updateViewport();
core.setGameCanvasTranslate('hero', 0, 0);
}
control.prototype._drawHero_getDrawObjs = function (direction, x, y, status, offset) {
@ -870,6 +853,48 @@ control.prototype.updateViewport = function() {
core.relocateCanvas('route', core.status.automaticRoute.offsetX - core.bigmap.offsetX, core.status.automaticRoute.offsetY - core.bigmap.offsetY);
}
////// 设置视野范围 //////
control.prototype.setViewport = function (x, y) {
core.bigmap.offsetX = core.clamp(x, 0, 32 * core.bigmap.width - core.__PIXELS__);
core.bigmap.offsetY = core.clamp(y, 0, 32 * core.bigmap.height - core.__PIXELS__);
this.updateViewport();
// ------ hero层也需要
var hero_x = core.clamp((core.getHeroLoc('x') - core.__HALF_SIZE__) * 32, 0, 32*core.bigmap.width-core.__PIXELS__);
var hero_y = core.clamp((core.getHeroLoc('y') - core.__HALF_SIZE__) * 32, 0, 32*core.bigmap.height-core.__PIXELS__);
core.control.setGameCanvasTranslate('hero', hero_x - core.bigmap.offsetX, hero_y - core.bigmap.offsetY);
}
////// 移动视野范围 //////
control.prototype.moveViewport = function (steps, time, callback) {
time = time || core.values.moveSpeed || 300;
var step = 0, moveSteps = (steps||[]).filter(function (t) {
return ['up','down','left','right'].indexOf(t)>=0;
});
var animate=window.setInterval(function() {
if (moveSteps.length==0) {
delete core.animateFrame.asyncId[animate];
clearInterval(animate);
if (callback) callback();
}
else {
if (core.control._moveViewport_moving(++step, moveSteps))
step = 0;
}
}, time / 16 / core.status.replay.speed);
core.animateFrame.asyncId[animate] = true;
}
control.prototype._moveViewport_moving = function (step, moveSteps) {
var direction = moveSteps[0], scan = core.utils.scan[direction];
core.setViewport(core.bigmap.offsetX + 2 * scan.x, core.bigmap.offsetY + 2 * scan.y);
if (step == 16) {
moveSteps.shift();
return true;
}
return false;
}
////// 获得勇士面对位置的x坐标 //////
control.prototype.nextX = function(n) {
if (n == null) n = 1;
@ -1211,7 +1236,7 @@ control.prototype.bookReplay = function () {
// 从“浏览地图”页面打开
if (core.status.event.id=='viewMaps')
core.status.event.selection = core.status.event.data;
core.status.event.ui = core.status.event.data;
core.lockControl();
core.status.event.id='book';
@ -2343,6 +2368,7 @@ control.prototype._updateStatusBar_setToolboxIcon = function () {
}
control.prototype.showStatusBar = function () {
if (main.mode == 'editor') return;
if (core.domStyle.showStatusBar) return;
var statusItems = core.dom.status;
core.domStyle.showStatusBar = true;
@ -2355,9 +2381,12 @@ control.prototype.showStatusBar = function () {
}
control.prototype.hideStatusBar = function (showToolbox) {
if (main.mode == 'editor') return;
// 如果原本就是隐藏的,则先显示
if (!core.domStyle.showStatusBar)
this.showStatusBar();
if (core.isReplaying()) showToolbox = true;
var statusItems = core.dom.status, toolItems = core.dom.tools;
core.domStyle.showStatusBar = false;
@ -2465,7 +2494,7 @@ control.prototype.setToolbarButton = function (useButton) {
}
if (useButton == null) useButton = core.domStyle.toolbarBtn;
if (!core.domStyle.isVertical || !core.platform.extendKeyboard) useButton = false;
if (!core.domStyle.isVertical || core.isReplaying()) useButton = false;
core.domStyle.toolbarBtn = useButton;
if (useButton) {
@ -2648,6 +2677,11 @@ control.prototype._resize_canvas = function (obj) {
canvas.style.left = parseFloat(canvas.getAttribute("_left")) * core.domStyle.scale + "px";
canvas.style.top = parseFloat(canvas.getAttribute("_top")) * core.domStyle.scale + "px";
}
// resize next
main.dom.next.style.width = main.dom.next.style.height = 5 * core.domStyle.scale + "px";
main.dom.next.style.borderBottomWidth = main.dom.next.style.borderRightWidth = 4 * core.domStyle.scale + "px";
}
control.prototype._resize_statusBar = function (obj) {

View File

@ -72,7 +72,6 @@ function core() {
'isChrome': false, // 是否是Chrome
'supportCopy': false, // 是否支持复制到剪切板
'useLocalForage': true,
'extendKeyboard': false,
'fileInput': null, // FileInput
'fileReader': null, // 是否支持FileReader
@ -285,7 +284,6 @@ core.prototype._init_platform = function () {
core.platform.isQQ = /QQ/i.test(navigator.userAgent);
core.platform.isWeChat = /MicroMessenger/i.test(navigator.userAgent);
this._init_checkLocalForage();
core.platform.extendKeyboard = core.getLocalStorage("extendKeyboard", false);
if (window.FileReader) {
core.platform.fileReader = new FileReader();
core.platform.fileReader.onload = function () {

View File

@ -462,7 +462,7 @@ events.prototype.getItem = function (id, num, x, y, callback) {
// --- 首次获得道具的提示
if (!core.hasFlag("__itemHint__")) core.setFlag("__itemHint__", []);
var itemHint = core.getFlag("__itemHint__");
if (itemHint.indexOf(id) < 0 && itemCls != 'items') {
if (core.flags.itemFirstText && itemHint.indexOf(id) < 0 && itemCls != 'items') {
var hint = core.material.items[id].text || "该道具暂无描述";
try {
hint = core.replaceText(hint);
@ -1030,8 +1030,10 @@ events.prototype._action_hide = function (data, x, y, prefix) {
}
events.prototype._action_setBlock = function (data, x, y, prefix) {
var loc = this.__action_getLoc(data.loc, x, y, prefix);
core.setBlock(data.number, loc[0], loc[1], data.floorId);
data.loc = this.__action_getLoc2D(data.loc, x, y, prefix);
data.loc.forEach(function (t) {
core.setBlock(data.number, t[0], t[1], data.floorId);
});
core.doAction();
}
@ -1052,8 +1054,10 @@ events.prototype._action_hideBgFgMap = function (data, x, y, prefix) {
}
events.prototype._action_setBgFgBlock = function (data, x, y, prefix) {
var loc = this.__action_getLoc(data.loc, x, y, prefix);
core.setBgFgBlock(data.name, data.number, loc[0], loc[1], data.floorId);
data.loc = this.__action_getLoc2D(data.loc, x, y, prefix);
data.loc.forEach(function (t) {
core.setBgFgBlock(data.name, data.number, t[0], t[1], data.floorId);
});
core.doAction();
}
@ -1073,6 +1077,21 @@ events.prototype._action_animate = function (data, x, y, prefix) {
this.__action_doAsyncFunc(data.async, core.drawAnimate, data.name, data.loc[0], data.loc[1]);
}
events.prototype._action_setViewport = function (data, x, y, prefix) {
if (data.loc == null) {
core.drawHero();
}
else {
var loc = this.__action_getLoc(data.loc, x, y, prefix);
core.setViewport(32 * loc[0], 32 * loc[1]);
}
core.doAction();
}
events.prototype._action_moveViewport = function (data, x, y, prefix) {
this.__action_doAsyncFunc(data.async, core.moveViewport, data.steps, data.time);
}
events.prototype._action_move = function (data, x, y, prefix) {
var loc = this.__action_getLoc(data.loc, x, y, prefix);
this.__action_doAsyncFunc(data.async, core.moveBlock, loc[0], loc[1], data.steps, data.time, data.keep);

View File

@ -939,24 +939,25 @@ maps.prototype._drawFloorImage = function (ctx, name, type, image, offsetX, widt
////// 绘制Autotile //////
maps.prototype._drawAutotile = function (ctx, mapArr, block, size, left, top, status) {
var indexArrs = [ //16种组合的图块索引数组; // 将autotile分割成48块16*16的小块; 数组索引即对应各个小块
// +----+----+----+----+----+----+
[10, 9, 4, 3], //0 bin:0000 | 1 | 2 | 3 | 4 | 5 | 6 |
[10, 9, 4, 13], //1 bin:0001 +----+----+----+----+----+----+
[10, 9, 18, 3], //2 bin:0010 | 7 | 8 | 9 | 10 | 11 | 12 |
[10, 9, 16, 15], //3 bin:0011 +----+----+----+----+----+----+
[10, 43, 4, 3], //4 bin:0100 | 13 | 14 | 15 | 16 | 17 | 18 |
[10, 31, 4, 25], //5 bin:0101 +----+----+----+----+----+----+
[10, 7, 2, 3], //6 bin:0110 | 19 | 20 | 21 | 22 | 23 | 24 |
[10, 31, 16, 5], //7 bin:0111 +----+----+----+----+----+----+
[48, 9, 4, 3], //8 bin:1000 | 25 | 26 | 27 | 28 | 29 | 30 |
[8, 9, 4, 1], //9 bin:1001 +----+----+----+----+----+----+
[36, 9, 30, 3], //10 bin:1010 | 31 | 32 | 33 | 34 | 35 | 36 |
[36, 9, 6, 15], //11 bin:1011 +----+----+----+----+----+----+
[46, 45, 4, 3], //12 bin:1100 | 37 | 38 | 39 | 40 | 41 | 42 |
[46, 11, 4, 25], //13 bin:1101 +----+----+----+----+----+----+
[12, 45, 30, 3], //14 bin:1110 | 43 | 44 | 45 | 46 | 47 | 48 |
[34, 33, 28, 27] //15 bin:1111 +----+----+----+----+----+----+
var indexArrs = [ //16种组合的图块索引数组;
// 将autotile分割成48块16*16的小块; 数组索引即对应各个小块
// +----+----+----+----+----+----+
[10, 9, 4, 3], //0 bin:0000 | 1 | 2 | 3 | 4 | 5 | 6 |
[10, 9, 4, 13], //1 bin:0001 +----+----+----+----+----+----+
[10, 9, 18, 3], //2 bin:0010 | 7 | 8 | 9 | 10 | 11 | 12 |
[10, 9, 16, 15], //3 bin:0011 +----+----+----+----+----+----+
[10, 43, 4, 3], //4 bin:0100 | 13 | 14 | 15 | 16 | 17 | 18 |
[10, 31, 4, 25], //5 bin:0101 +----+----+----+----+----+----+
[10, 43, 18, 3], //6 bin:0110 | 19 | 20 | 21 | 22 | 23 | 24 |
[10, 31, 16, 5], //7 bin:0111 +----+----+----+----+----+----+
[48, 9, 4, 3], //8 bin:1000 | 25 | 26 | 27 | 28 | 29 | 30 |
[48, 9, 4, 13], //9 bin:1001 +----+----+----+----+----+----+
[36, 9, 30, 3], //10 bin:1010 | 31 | 32 | 33 | 34 | 35 | 36 |
[36, 9, 6, 15], //11 bin:1011 +----+----+----+----+----+----+
[46, 45, 4, 3], //12 bin:1100 | 37 | 38 | 39 | 40 | 41 | 42 |
[46, 11, 4, 25], //13 bin:1101 +----+----+----+----+----+----+
[12, 45, 30, 3], //14 bin:1110 | 43 | 44 | 45 | 46 | 47 | 48 |
[20, 23, 38, 41] //15 bin:1111 +----+----+----+----+----+----+
];
// 开始绘制autotile

View File

@ -452,6 +452,7 @@ ui.prototype.closePanel = function () {
ui.prototype.clearUI = function () {
core.status.boxAnimateObjs = [];
if (core.dymCanvas._selector) core.deleteCanvas("_selector");
main.dom.next.style.display = 'none';
core.clearMap('ui');
core.setAlpha('ui', 1);
}
@ -640,7 +641,6 @@ ui.prototype._getPosition = function (content) {
ui.prototype.drawWindowSelector = function(background, x, y, w, h) {
w = Math.round(w), h = Math.round(h);
var ctx = core.ui.createCanvas("_selector", x, y, w, h, 165);
ctx.canvas.style.opacity = 0.8;
this._drawSelector(ctx, background, w, h);
}
@ -662,7 +662,6 @@ ui.prototype._uievent_drawSelector = function (data) {
var z = 136;
if (core.dymCanvas.uievent) z = (parseInt(core.dymCanvas.uievent.canvas.style.zIndex) || 135) + 1;
var ctx = core.createCanvas('_uievent_selector', x, y, w, h, z);
ctx.canvas.style.opacity = 0.8;
this._drawSelector(ctx, background, w, h);
}
@ -1119,10 +1118,20 @@ ui.prototype.drawTextBox = function(content, showAll) {
var content_top = this._drawTextBox_drawTitleAndIcon(titleInfo, hPos, vPos, alpha);
// Step 5: 绘制正文
return this.drawTextContent('ui', content, {
var config = this.drawTextContent('ui', content, {
left: hPos.content_left, top: content_top, maxWidth: hPos.validWidth,
lineHeight: vPos.lineHeight, time: (showAll || textAttribute.time<=0 || core.status.event.id!='action')?0:textAttribute.time
});
// Step 6: 绘制光标
main.dom.next.style.display = 'block';
main.dom.next.style.borderRightColor = main.dom.next.style.borderBottomColor = core.arrayToRGB(textAttribute.text);
main.dom.next.style.top = (vPos.bottom - 20) * core.domStyle.scale + "px";
var left = (hPos.left + hPos.right) / 2;
if (pInfo.position == 'up' && pInfo.px != null && Math.abs(pInfo.px * 32 + 16 - left) < 50)
left = hPos.right - 64;
main.dom.next.style.left = left * core.domStyle.scale + "px";
return config;
}
ui.prototype._drawTextBox_drawImages = function (content) {
@ -1170,7 +1179,7 @@ ui.prototype._drawTextBox_getHorizontalPosition = function (content, titleInfo,
ui.prototype._drawTextBox_getVerticalPosition = function (content, titleInfo, posInfo, validWidth) {
var textAttribute = core.status.textAttribute || core.initStatus.textAttribute;
var lineHeight = textAttribute.textfont + 6;
var height = 30 + this.getTextContentHeight(content, {
var height = 45 + this.getTextContentHeight(content, {
lineHeight: lineHeight, maxWidth: validWidth
});
if (titleInfo.title) height += textAttribute.titlefont + 5;
@ -1507,7 +1516,6 @@ ui.prototype.drawSwitchs = function() {
"领域显伤: "+(core.flags.displayExtraDamage ? "[ON]" : "[OFF]"),
"新版存档: "+(core.platform.useLocalForage ? "[ON]":"[OFF]"),
"单击瞬移: "+(!core.hasFlag("__noClickMove__") ? "[ON]":"[OFF]"),
"拓展键盘: "+(core.platform.extendKeyboard ? "[ON]":"[OFF]"),
"返回主菜单"
];
this.drawChoices(null, choices);

31
main.js
View File

@ -74,7 +74,8 @@ function main() {
'inputMessage': document.getElementById('inputMessage'),
'inputBox': document.getElementById('inputBox'),
'inputYes': document.getElementById('inputYes'),
'inputNo': document.getElementById('inputNo')
'inputNo': document.getElementById('inputNo'),
'next': document.getElementById('next')
};
this.mode = 'play';
this.loadList = [
@ -216,6 +217,7 @@ main.prototype.init = function (mode, callback) {
})(span,value[1]);
main.dom.levelChooseButtons.appendChild(span);
});
main.createOnChoiceAnimation();
main.loadJs('libs', main.loadList, function () {
main.core = core;
@ -328,14 +330,32 @@ main.prototype.log = function (e) {
}
}
main.prototype.createOnChoiceAnimation = function () {
var borderColor = main.dom.startButtonGroup.style.caretColor || "rgb(255, 215, 0)";
// get rgb value
var rgb = /^rgba?\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(,\s*\d+\s*)?\)$/.exec(borderColor);
if (rgb != null) {
var value = rgb[1] + ", " + rgb[2] + ", " + rgb[3];
var style = document.createElement("style");
style.type = 'text/css';
var keyFrames = "onChoice { " +
"0% { border-color: rgba("+value+", 0.9); } " +
"50% { border-color: rgba("+value+", 0.3); } " +
"100% { border-color: rgba("+value+", 0.9); } " +
"}";
style.innerHTML = "@-webkit-keyframes " + keyFrames + " @keyframes " + keyFrames;
document.body.appendChild(style);
}
}
////// 选项 //////
main.prototype.selectButton = function (index) {
var select = function (children) {
index = (index + children.length) % children.length;
for (var i = 0;i < children.length; ++i) {
children[i].style.borderColor = 'transparent';
children[i].classList.remove("onChoiceAnimate");
}
children[index].style.borderColor = main.dom.startButtonGroup.style.caretColor || '#FFD700';
children[index].classList.add("onChoiceAnimate");
if (main.selectedButton == index) {
children[index].click();
}
@ -383,6 +403,9 @@ main.dom.body.onkeyup = function(e) {
main.selectButton((main.selectedButton||0) + 1);
else if (e.keyCode == 67 || e.keyCode == 13 || e.keyCode == 32) // C/Enter/Space
main.selectButton(main.selectedButton);
else if (e.keyCode == 27 && main.dom.levelChooseButtons.style.display == 'block') { // ESC
main.core.showStartAnimate(true);
}
e.stopPropagation();
return;
}
@ -642,7 +665,7 @@ main.statusBar.image.settings.onclick = function (e) {
}
////// 点击工具栏时 //////
main.dom.toolBar.onclick = function () {
main.dom.hard.onclick = function () {
if (core.isReplaying())
return;
main.core.control.setToolbarButton(!core.domStyle.toolbarBtn);

View File

@ -396,6 +396,7 @@ var data_a1e2fb4a_e986_4524_b0da_9b7ba7c0874d =
"snowFourDirections": false,
"bigKeyIsBox": false,
"steelDoorWithoutKey": false,
"itemFirstText": true,
"equipment": false,
"equipboxButton": false,
"iconInEquipbox": false,

View File

@ -159,6 +159,10 @@
border-radius: 6px;
}
.onChoiceAnimate {
animation: onChoice 2s ease-in-out 0s infinite normal none running;
}
#floorMsgGroup {
top: 3px;
right: 3px;
@ -374,4 +378,49 @@ p#name {
#inputNo {
float:right;
margin-right: 10%;
}
#_selector, #_uievent_selector {
animation: selector 2s ease-in-out 0s infinite normal none running;
}
@-webkit-keyframes selector {
0% { opacity: 0.95; }
50% { opacity: 0.55; }
100% { opacity: 0.95; }
}
@keyframes selector {
0% { opacity: 0.95; }
50% { opacity: 0.55; }
100% { opacity: 0.95; }
}
#next {
width: 5px;
height: 5px;
display: none;
position: absolute;
transform: rotate(45deg);
border-bottom-width: 4px;
border-bottom-style: solid;
border-right-width: 4px;
border-right-style: solid;
-webkit-animation: next .5s ease-in-out alternate infinite;
animation: next .5s ease-in-out alternate infinite;
left: 0;
top: 0;
opacity: 0.7;
z-index: 169;
}
@-webkit-keyframes next {
100% {
transform: rotate(45deg) translate(-3px, -3px);
}
}
@keyframes next {
100% {
transform: rotate(45deg) translate(-3px, -3px);
}
}

View File

@ -1,9 +1,10 @@
HTML5魔塔样板V2.6.3
标题界面大幅美化,支持键盘开始游戏
标题界面大幅美化,增加闪烁光标,支持键盘开始游戏
事件编辑器支持自动补全能对flag和API列表等进行补全
剧情文本中\\c修改字体大小\\d和\\e切换粗体和斜体
可以指定每个选择项的出现条件,动态生成
事件:设置视角&移动视角
可以指定显示选择项的出现条件并动态生成
楼层传送器的平面传送模式(哪里离开飞回到哪里)
UI绘制事件增添绘制圆和绘制圆边框
所有的UI绘制事件均可以双击预览