Merge remote-tracking branch 'refs/remotes/ckcz123/v2.x' into refactoring-editor

This commit is contained in:
YouWei Zhao 2019-04-18 19:21:19 -04:00
commit 73ebf73f17
10 changed files with 114 additions and 35 deletions

View File

@ -1706,6 +1706,7 @@ core.drawTip(text, id)
在左上角以气泡的形式绘制一段提示。
text为文字内容仅支持${}的表达式计算,不支持换行和变色。
id可选为同时绘制的图标ID如果不为null则会同时绘制该图标仅对32x32的素材有效
也可以使用状态栏的图标ID例如lv, hp, up, save, settings等。
core.drawText(content, callback)

View File

@ -209,17 +209,28 @@
- `\b[up]` 直接显示在当前点上方。同样把这里的up换成down则为下方。
- 如果不存在当前点如在firstArrive或eachArrive中调用则显示在屏幕最上方最下方
- `\b[up,hero]` 显示在勇士上方。同样把这里的up换成down则为下方。
- `\b[up,x,y]` 显示在(x,y)点的上方下方x和y都为整数且在0到12之间。
- 从V2.6开始,也允许写`\b[hero]`来根据勇士位置自动决定上方还是下方
- `\b[up,x,y]` 显示在(x,y)点的上方下方x和y都为整数且在0到12之间
- 从V2.6开始,也允许写`\b[null,x,y]`来根据(x,y)位置自动决定上方还是下方
- `\b[up,x]` 显示在勇士的第x个跟随的行走图的上方下方也允许把up换成null来自动适配
``` js
[
"\b[up]这段文字显示在当前点上方",
"\b[down]这段文字显示在当前点上方",
"\t[hero]\b[up,hero]这是一段勇士说的话,会显示在勇士上方",
"\t[hero]\b[hero]这是一段勇士说的话,根据勇士位置自动适配上下",
"\t[小妖精,fairy]\b[down,2,2]这是一段小妖精说的话,会显示在(2,2)点下方",
"\t[null,1,3]根据坐标位置自动适配上下",
"\t[up,1]"显示在勇士第一个跟随的行走图上方",
"\t[null,2]显示在勇士第二个跟随的行走图,自动适配上下",
]
```
从V2.6开始,`\b`提供了更多功能,包括:
- `\b[hero]`
!> `\t[...]`必须在`\b[...]`前面!不然两者都无法正常显示。
还可以使用`\r[...]`来调整剧情文本的颜色。
@ -366,11 +377,13 @@ time为可选项表示文字添加的速度。若此项设置为0将直接全
``` js
[
{"type": "tip", "text": "这段话将在左上角以气泡形式显示"}
{"type": "tip", "text": "这段话将在左上角以气泡形式显示", "icon": "book"}
]
```
值得注意的是提示的text内容也是可以使用`${ }`来计算表达式的值的。
text必填为显示的内容支持`${}`的表达式计算。
icon是可选的如果设置则会绘制图标其可以是一个有效的ID或者`core.statusBar.icons`中的系统图标。
### comment添加注释
@ -1400,6 +1413,10 @@ async可选如果为true则会异步执行即不等待当前事件执行
在玩家进行一次存档,或者直接点返回游戏后,将接着执行后面的事件。录像播放将会跳过本事件。
### autoSave自动存档
`{"type": "autoSave"}` 可以立刻进行一次自动存档。录像播放不会跳过本事件。
### callLoad呼出读档界面
`{"type": "callLoad"}` 可以呼出读档页面并允许玩家进行读档。

View File

@ -338,6 +338,7 @@ action
| confirm_s
| callBook_s
| callSave_s
| autoSave_s
| callLoad_s
| unknown_s
| function_s
@ -482,14 +483,15 @@ return code;
*/;
tip_s
: '显示提示' ':' EvalString Newline
: '显示提示' ':' EvalString '图标ID' IdString? Newline
/* tip_s
tooltip : tip显示一段提示文字
helpUrl : https://h5mota.com/games/template/docs/#/event?id=tip%EF%BC%9A%E6%98%BE%E7%A4%BA%E4%B8%80%E6%AE%B5%E6%8F%90%E7%A4%BA%E6%96%87%E5%AD%97
default : ["这段话将在左上角以气泡形式显示"]
var code = '{"type": "tip", "text": "'+EvalString_0+'"},\n';
default : ["这段话将在左上角以气泡形式显示",""]
IdString_0 = IdString_0 && (', "icon": "' + IdString_0 + '"');
var code = '{"type": "tip", "text": "'+EvalString_0+'"'+IdString_0+'},\n';
return code;
*/;
@ -1799,7 +1801,7 @@ callSave_s
/* callSave_s
tooltip : callSave: 呼出存档页面之后读此档将执行eachArrive
tooltip : callSave: 呼出存档页面
helpUrl : https://h5mota.com/games/template/docs/#/event?id=callSave%ef%bc%9a%e5%91%bc%e5%87%ba%e5%ad%98%e6%a1%a3%e7%95%8c%e9%9d%a2
colour : this.soundColor
var code = '{"type": "callSave"},\n';
@ -1807,6 +1809,19 @@ return code;
*/;
autoSave_s
: '自动存档'
/* autoSave_s
tooltip : autoSave: 自动存档
helpUrl : https://h5mota.com/games/template/docs/#/event?id=autoSave%ef%bc%9a%e8%87%aa%e5%8a%a8%e5%ad%98%e6%a1%a3
colour : this.soundColor
var code = '{"type": "autoSave"},\n';
return code;
*/;
callLoad_s
: '呼出读档页面'
@ -2323,7 +2338,7 @@ ActionParser.prototype.parseAction = function() {
break;
case "tip":
this.next = MotaActionBlocks['tip_s'].xmlText([
data.text,this.next]);
data.text,data.icon||"",this.next]);
break;
case "show": // 显示
data.loc=data.loc||[];
@ -2750,6 +2765,10 @@ ActionParser.prototype.parseAction = function() {
this.next = MotaActionBlocks['callSave_s'].xmlText([
this.next]);
break;
case "autoSave": // 自动存档
this.next = MotaActionBlocks['autoSave_s'].xmlText([
this.next]);
break;
case "callLoad": // 呼出读档界面
this.next = MotaActionBlocks['callLoad_s'].xmlText([
this.next]);

View File

@ -161,6 +161,7 @@ editor_blockly = function () {
MotaActionBlocks['setVolume_s'].xmlText(),
MotaActionBlocks['callBook_s'].xmlText(),
MotaActionBlocks['callSave_s'].xmlText(),
MotaActionBlocks['autoSave_s'].xmlText(),
MotaActionBlocks['callLoad_s'].xmlText(),
],
'原生脚本':[
@ -672,11 +673,11 @@ function omitedcheckUpdateFunction(event) {
var searchInput = document.getElementById("searchBlock");
searchInput.onfocus = function () {
editor_blockly.reopenToolbox(9);
editor_blockly.reopenToolbox(10);
}
searchInput.oninput = function () {
editor_blockly.reopenToolbox(9);
editor_blockly.reopenToolbox(10);
}
editor_blockly.searchBlock = function (value) {

View File

@ -744,11 +744,18 @@ actions.prototype._sys_longClick_lockControl = function (x, y) {
}
// 长按楼传器的箭头可以快速翻页
if (core.status.event.id == 'fly') {
if ((x == 10 || x == 11) && (y == 5 || y == 9)) {
if ((x == this.SIZE-2 || x == this.SIZE-3) && (y == this.HSIZE - 1 || y == this.HSIZE+3)) {
this._clickFly(x, y);
return true;
}
}
// 长按SL快速翻页
if (["save","load","replayLoad"].indexOf(core.status.event.id) >= 0) {
if ([this.HSIZE-2, this.HSIZE-3, this.HSIZE+2, this.HSIZE+3].indexOf(x) >= 0 && y == this.LAST) {
this._clickSL(x, y);
return true;
}
}
// 长按可以跳过等待事件
if (core.status.event.id == 'action' && core.status.event.data.type == 'sleep'
&& !core.status.event.data.current.noSkip) {

View File

@ -1098,9 +1098,10 @@ control.prototype.speedUpReplay = function () {
if (core.status.replay.speed==12) core.status.replay.speed=24;
else if (core.status.replay.speed==6) core.status.replay.speed=12;
else if (core.status.replay.speed==3) core.status.replay.speed=6;
else if (core.status.replay.speed<3) {
var toAdd = core.status.replay.speed>=2?2:1;
core.status.replay.speed = parseInt(10*core.status.replay.speed + toAdd)/10;
else if (core.status.replay.speed==2.5) core.status.replay.speed=3;
else if (core.status.replay.speed==2) core.status.replay.speed=2.5;
else {
core.status.replay.speed = parseInt(10*core.status.replay.speed + 2)/10;
}
core.drawTip("x"+core.status.replay.speed+"倍");
}
@ -1108,14 +1109,15 @@ control.prototype.speedUpReplay = function () {
////// 减速播放 //////
control.prototype.speedDownReplay = function () {
if (!core.isPlaying() || !core.isReplaying()) return;
if (core.status.replay.speed==24) core.status.replay.speed=12.0;
else if (core.status.replay.speed==12) core.status.replay.speed=6.0;
else if (core.status.replay.speed==6) core.status.replay.speed=3.0;
if (core.status.replay.speed==24) core.status.replay.speed=12;
else if (core.status.replay.speed==12) core.status.replay.speed=6;
else if (core.status.replay.speed==6) core.status.replay.speed=3;
else if (core.status.replay.speed==3) core.status.replay.speed=2.5;
else if (core.status.replay.speed==2.5) core.status.replay.speed=2;
else {
var toAdd = core.status.replay.speed>=2?2:1;
core.status.replay.speed = parseInt(10*core.status.replay.speed - toAdd)/10;
core.status.replay.speed = parseInt(10*core.status.replay.speed - 2)/10;
}
if (core.status.replay.speed<0.3) core.status.replay.speed=0.3;
if (core.status.replay.speed<0.2) core.status.replay.speed=0.2;
core.drawTip("x"+core.status.replay.speed+"倍");
}
@ -1480,15 +1482,21 @@ control.prototype._replayAction_key = function (action) {
////// 自动存档 //////
control.prototype.autosave = function (removeLast) {
if (core.status.event.id!=null) return;
var x=null;
if (removeLast) x=core.status.route.pop();
core.status.route.push("turn:"+core.getHeroLoc('direction'));
if (removeLast) {
x=core.status.route.pop();
core.status.route.push("turn:"+core.getHeroLoc('direction'));
}
if (core.status.event.id == 'action') // 事件中的自动存档
core.setFlag("__events__", core.clone(core.status.event.data));
core.saves.autosave.data = core.saveData();
core.saves.autosave.updated = true;
core.saves.ids[0] = true;
core.status.route.pop();
if (x) core.status.route.push(x);
core.removeFlag("__events__");
if (removeLast) {
core.status.route.pop();
if (x) core.status.route.push(x);
}
}
/////// 实际进行自动存档 //////

View File

@ -287,8 +287,12 @@ events.prototype.doSystemEvent = function (type, data, callback) {
////// 触发(x,y)点的事件 //////
events.prototype._trigger = function (x, y) {
// 如果已经死亡,或正处于某事件中,则忽略
if (core.status.gameOver || core.status.event.id) return;
if (core.status.gameOver) return;
if (core.status.event.id == 'action') {
core.insertAction({"type": "trigger", "loc": [x, y]}, x, y, null, true);
return;
}
if (core.status.event.id) return;
var block = core.getBlock(x, y);
if (block == null) return;
@ -952,7 +956,7 @@ events.prototype._action_setText = function (data, x, y, prefix) {
}
events.prototype._action_tip = function (data, x, y, prefix) {
core.drawTip(core.replaceText(data.text));
core.drawTip(core.replaceText(data.text), data.icon);
core.doAction();
}
@ -1579,6 +1583,12 @@ events.prototype._action_callSave = function (data, x, y, prefix) {
}
}
events.prototype._action_autoSave = function (data, x, y, prefix) {
core.autosave();
core.drawTip("已自动存档");
core.doAction();
}
events.prototype._action_callLoad = function (data, x, y, prefix) {
if (this.__action_checkReplaying()) return;
var e = core.clone(core.status.event.data);

View File

@ -275,7 +275,13 @@ ui.prototype.drawTip = function (text, id) {
core.setTextAlign('data', 'left');
if (id != null) {
var info = core.getBlockInfo(id);
if (info == null || !info.image || info.height != 32) id = null;
if (info == null || !info.image || info.height != 32) {
// 检查状态栏图标
if (core.statusBar.icons[id] instanceof Image) {
id = {image: core.statusBar.icons[id], posX: 0, posY: 0};
}
else id = null;
}
else id = info;
}
if (!id) {
@ -374,6 +380,7 @@ ui.prototype._getTitleAndIcon = function (content) {
var blockInfo = core.getBlockInfo(s4);
if (blockInfo != null) {
if (core.material.enemys[s4]) title = core.material.enemys[s4].name;
else title = s4;
image = blockInfo.image;
icon = blockInfo.posY;
height = blockInfo.height;
@ -403,9 +410,9 @@ ui.prototype._getPosition = function (content) {
py = core.status.event.data.y;
}
content = content.replace("\b", "\\b")
.replace(/\\b\[(up|center|down|hero|null)(,(hero|null|\d+,\d+))?]/g, function (s0, s1, s2, s3) {
.replace(/\\b\[(up|center|down|hero|null)(,(hero|null|\d+,\d+|\d+))?]/g, function (s0, s1, s2, s3) {
pos = s1;
if (s3 == 'hero' || s1=='hero') {
if (s3 == 'hero' || s1=='hero' && !s3) {
px = core.status.hero.loc.x;
py = core.status.hero.loc.y;
}
@ -414,8 +421,17 @@ ui.prototype._getPosition = function (content) {
}
else if (s3) {
var str = s3.split(',');
px = parseInt(str[0]);
py = parseInt(str[1]);
px = py = null;
if (str.length == 1) {
var follower = (core.status.hero.followers||[])[parseInt(str[0])-1];
if (follower) {
px = follower.x;
py = follower.y;
}
} else{
px = parseInt(str[0]);
py = parseInt(str[1]);
}
}
if(pos=='hero' || pos=='null'){
pos = py==null?'center':(py>=core.__HALF_SIZE__? 'up':'down');

View File

@ -14,7 +14,7 @@ function main() {
this.isCompetition = false; // 是否是比赛模式
this.savePages = 100; // 存档页数每页可存5个默认为100页500个存档
this.savePages = 1000; // 存档页数每页可存5个默认为1000页5000个存档
//------------------------ 用户修改内容 END ------------------------//

View File

@ -63,7 +63,7 @@ var data_a1e2fb4a_e986_4524_b0da_9b7ba7c0874d =
"statusLeftBackground": "url(project/images/ground.png) repeat",
"statusTopBackground": "url(project/images/ground.png) repeat",
"toolsBackground": "url(project/images/ground.png) repeat",
"borderColor": "white",
"borderColor": "#CCCCCC",
"statusBarColor": "white",
"hardLabelColor": "red",
"floorChangingBackground": "black",