moveEnemyOnPoint dxy & setDisplayScale

This commit is contained in:
ckcz123 2021-08-05 19:10:55 +08:00
parent 61f42bd6c5
commit 4dc47a5d58
10 changed files with 72 additions and 23 deletions

View File

@ -573,6 +573,9 @@ color: 一行三列第四列视为1或一行四列第四列若大于1
time: 渐变时间单位为毫秒。不填视为750ms负数视为0无渐变立即更改
callback: 更改完毕后的回调函数可选。事件流中常取core.doAction
setDisplayScale: fn(delta: number)
设置屏幕放缩
setFlag: fn(name: string, value: ?)
设置一个flag变量
例如core.setFlag('poison', true); // 令主角中毒

View File

@ -2560,6 +2560,10 @@ var terndefs_f6783a0a_522d_417e_8407_94c67b692e50 = [
"!doc": "检查bgm状态",
"!type": "fn()"
},
"setDisplayScale": {
"!doc": "设置屏幕放缩",
"!type": "fn(delta: number)"
},
"speedDownReplay": {
"!doc": "减速播放",
"!type": "fn()"

View File

@ -780,6 +780,7 @@ action
| setEnemyOnPoint_s
| resetEnemyOnPoint_s
| moveEnemyOnPoint_s
| moveEnemyOnPoint_1_s
| setEquip_s
| setFloor_s
| setGlobalAttribute_s
@ -1257,6 +1258,24 @@ var code = '{"type": "moveEnemyOnPoint"'+floorstr+IdString_0+'},\n';
return code;
*/;
moveEnemyOnPoint_1_s
: '移动某点怪物属性' ':' '起点' 'x' PosString? ',' 'y' PosString? '增量' 'dx' PosString? 'dy' PosString? '楼层' IdString? Newline
/* moveEnemyOnPoint_1_s
tooltip : moveEnemyOnPoint移动某个点上怪物的属性到其他点
helpUrl : /_docs/#/instruction
default : ["", "", "", "", ""]
allFloorIds : ['IdString_0']
selectPoint : ["PosString_0", "PosString_1"]
colour : this.dataColor
IdString_0 = IdString_0 && (', "floorId": "'+IdString_0+'"');
var floorstr = PosString_0 && PosString_1 ? ', "from": ['+PosString_0+','+PosString_1+']' : '';
if (PosString_2 && PosString_3) floorstr += ', "dxy": ['+PosString_2+','+PosString_3+']'
var code = '{"type": "moveEnemyOnPoint"'+floorstr+IdString_0+'},\n';
return code;
*/;
setFloor_s
: '设置楼层属性' ':' Floor_Meta_List '楼层名' IdString? '为' JsonEvalString Newline

View File

@ -750,9 +750,14 @@ ActionParser.prototype.parseAction = function() {
break;
case "moveEnemyOnPoint":
data.from=data.from||['','']
data.to=data.to||['','']
this.next = MotaActionBlocks['moveEnemyOnPoint_s'].xmlText([
data.from[0], data.from[1], data.to[0], data.to[1], data.floorId||'',this.next]);
if (data.dxy) {
this.next = MotaActionBlocks['moveEnemyOnPoint_1_s'].xmlText([
data.from[0], data.from[1], data.dxy[0], data.dxy[1], data.floorId||'',this.next]);
} else {
data.to=data.to||['','']
this.next = MotaActionBlocks['moveEnemyOnPoint_s'].xmlText([
data.from[0], data.from[1], data.to[0], data.to[1], data.floorId||'',this.next]);
}
break;
case "setEquip":
this.next = MotaActionBlocks['setEquip_s'].xmlText([

View File

@ -126,6 +126,7 @@ editor_blocklyconfig=(function(){
MotaActionBlocks['setEnemyOnPoint_s'].xmlText(),
MotaActionBlocks['resetEnemyOnPoint_s'].xmlText(),
MotaActionBlocks['moveEnemyOnPoint_s'].xmlText(),
MotaActionBlocks['moveEnemyOnPoint_1_s'].xmlText(),
MotaActionBlocks['setEquip_s'].xmlText(),
MotaActionBlocks['setFloor_s'].xmlText(),
MotaActionBlocks['setGlobalAttribute_s'].xmlText(),

View File

@ -2262,13 +2262,7 @@ actions.prototype._clickSwitchs_display = function (x, y) {
}
actions.prototype._clickSwitchs_display_setSize = function (delta) {
var index = core.domStyle.availableScale.indexOf(core.domStyle.scale);
if (index < 0) return;
index += delta;
if (index < 0 || index >= core.domStyle.availableScale.length);
core.domStyle.scale = core.domStyle.availableScale[index];
core.setLocalStorage('scale', core.domStyle.scale);
core.resize();
core.setDisplayScale(delta);
var currentRatio = Math.max(window.devicePixelRatio || 1, core.domStyle.scale);
if (currentRatio > core.domStyle.ratio) {
core.drawTip("需刷新页面以调整UI清晰度");

View File

@ -2858,19 +2858,15 @@ control.prototype.checkBgm = function() {
core.playBgm(core.musicStatus.playingBgm || main.startBgm);
}
///// 设置屏幕大小 //////
control.prototype.setDisplaySize = function (delta) {
///// 设置屏幕放缩 //////
control.prototype.setDisplayScale = function (delta) {
var index = core.domStyle.availableScale.indexOf(core.domStyle.scale);
if (index < 0) return;
index += delta;
if (index < 0 || index >= core.domStyle.availableScale.length);
if (index < 0 || index >= core.domStyle.availableScale.length) return;
core.domStyle.scale = core.domStyle.availableScale[index];
core.setLocalStorage('scale', core.domStyle.scale);
core.resize();
var currentRatio = Math.max(window.devicePixelRatio || 1, core.domStyle.scale);
if (currentRatio > core.domStyle.ratio && core.isPlaying()) {
core.drawTip("需刷新页面以调整UI清晰度");
}
}
// ------ 状态栏,工具栏等相关 ------ //

View File

@ -1876,12 +1876,17 @@ events.prototype._action_resetEnemyOnPoint = function (data, x, y, prefix) {
events.prototype._precompile_moveEnemyOnPoint = function (data) {
data.from = this.__precompile_array(data.from);
data.to = this.__precompile_array(data.to);
data.dxy = this.__precompile_array(data.dxy);
return data;
}
events.prototype._action_moveEnemyOnPoint = function (data, x, y, prefix) {
var from = this.__action_getLoc(data.from, x, y, prefix);
var to = this.__action_getLoc(data.to, x, y, prefix);
var from = this.__action_getLoc(data.from, x, y, prefix), to;
if (data.dxy) {
to = [from[0] + (core.calValue(data.dxy[0], prefix) || 0), from[1] + (core.calValue(data.dxy[1], prefix) || 0)];
} else {
to = this.__action_getLoc(data.to, x, y, prefix);
}
this.moveEnemyOnPoint(from[0], from[1], to[0], to[1], data.floorId);
core.doAction();
}
@ -1944,8 +1949,11 @@ events.prototype.__action_getInput = function (hint, isText, callback) {
if (core.isReplaying()) {
var action = core.status.replay.toReplay.shift();
try {
if (action.indexOf(prefix) != 0)
throw new Error("录像文件出错!当前需要一个 " + prefix + " 项,实际为 " + action);
if (action.indexOf(prefix) != 0) {
console.warn("警告!当前需要一个 " + prefix + " 项,实际为 " + action);
core.status.replay.toReplay.unshift(action);
return callback(isText ? '' : 0);
}
if (isText) value = core.decodeBase64(action.substring(7));
else value = parseInt(action.substring(6));
callback(value);
@ -2404,11 +2412,13 @@ events.prototype.__action_wait_afterGet = function (data) {
if (!data.data) return false;
var todo = [];
var stop = false;
var found = false;
data.data.forEach(function (one) {
if (one._disabled || stop) return;
if (one["case"] == "keyboard" && core.getFlag("type") == 0) {
(one.keycode + "").split(",").forEach(function (keycode) {
if (core.getFlag("keycode", 0) == keycode) {
found = true;
core.push(todo, one.action);
if (one["break"]) stop = true;
}
@ -2422,6 +2432,7 @@ events.prototype.__action_wait_afterGet = function (data) {
var pymax = core.calValue(one.py[1]);
var px = core.getFlag("px", 0), py = core.getFlag("py", 0);
if (px >= pxmin && px <= pxmax && py >= pymin && py <= pymax) {
found = true;
core.push(todo, one.action);
if (one["break"]) stop = true;
}
@ -2430,16 +2441,18 @@ events.prototype.__action_wait_afterGet = function (data) {
var condition = false;
try { condition = core.calValue(one.condition); } catch (e) {}
if (condition) {
found = true;
core.push(todo, one.action);
if (one["break"]) stop = true;
}
}
if (one["case"] == "timeout" && core.getFlag("type") == -1) {
found = true;
core.push(todo, one.action);
if (one["break"]) stop = true;
}
})
if (todo.length > 0) {
if (found) {
core.insertAction(todo);
return true;
}
@ -2496,7 +2509,10 @@ events.prototype._action_callSave = function (data, x, y, prefix) {
}
events.prototype._action_autoSave = function (data, x, y, prefix) {
var forbidSave = core.hasFlag('__forbidSave__');
core.removeFlag('__forbidSave__');
core.autosave();
if (forbidSave) core.setFlag('__forbidSave__', true);
if (!data.nohint) core.drawTip("已自动存档");
core.doAction();
}

10
main.js
View File

@ -763,7 +763,15 @@ main.dom.musicBtn.onclick = function () {
}
main.dom.enlargeBtn.onclick = function () {
try {
if (main.core) {
main.core.setDisplayScale(1);
if (!main.core.isPlaying() && main.core.flags.enableHDCanvas) {
main.core.domStyle.ratio = Math.max(window.devicePixelRatio || 1, main.core.domStyle.scale);
main.core.resize();
}
}
} catch (e) {main.log(e)};
}
window.onblur = function () {

3
runtime.d.ts vendored
View File

@ -792,6 +792,9 @@ declare class control {
/** 检查bgm状态 */
checkBgm(): void
/** 设置屏幕放缩 */
setDisplayScale(delta: number): void
/** 清空状态栏 */
clearStatusBar(): void