录像容错

This commit is contained in:
ckcz123 2021-07-22 17:23:16 +08:00
parent 5a6bb9f82e
commit 8cecec0334

View File

@ -1893,6 +1893,46 @@ events.prototype._action_choices = function (data, x, y, prefix) {
if (action.indexOf('choices:') == 0) {
var index = action.substring(8);
if (index == 'none' || ((index = parseInt(index)) >= 0) && index % 100 < data.choices.length) {
this.__action_choices_replaying(data, index);
} else {
core.control._replay_error(action);
return;
}
} else {
// 容错录像
if (main.replayChecking) {
core.control._replay_error(action);
return;
}
core.myprompt('录像回放出错!当前需要执行选择项但录像中未记录。\n如需修复请输入您要选的项从0起点击取消将不会修复。', 0, function (value) {
if (value == null) {
core.control._replay_error(action);
return;
}
core.status.replay.toReplay.unshift(action); // 首先归还刚才读出的下一步操作
value = core.clamp(parseInt(value), 0, data.choices.length - 1);
core.events.__action_choices_replaying(data, core.clamp(value, 0, data.choices.length - 1))
});
}
} else {
if (data.timeout) {
core.status.event.interval = setTimeout(function () {
core.status.route.push("choices:none");
core.setFlag('timeout', 0);
core.doAction();
}, data.timeout);
}
core.status.event.timeout = new Date().getTime() + (data.timeout || 0);
}
for (var i = 0; i < data.choices.length; i++) {
if (typeof data.choices[i] === 'string')
data.choices[i] = {"text": data.choices[i]};
data.choices[i].text = core.replaceText(data.choices[i].text, prefix);
}
core.ui.drawChoices(core.replaceText(data.text, prefix), data.choices);
}
events.prototype.__action_choices_replaying = function (data, index) {
if (index != 'none') {
var timeout = Math.floor(index / 100) || 0;
core.setFlag('timeout', timeout);
@ -1913,27 +1953,6 @@ events.prototype._action_choices = function (data, x, y, prefix) {
core.doAction();
}, core.status.replay.speed == 24 ? 1 : 750 / Math.max(1, core.status.replay.speed));
}
} else {
core.control._replay_error(action);
return;
}
} else {
if (data.timeout) {
core.status.event.interval = setTimeout(function () {
core.status.route.push("choices:none");
core.setFlag('timeout', 0);
core.doAction();
}, data.timeout);
}
core.status.event.timeout = new Date().getTime() + (data.timeout || 0);
}
for (var i = 0; i < data.choices.length; i++) {
if (typeof data.choices[i] === 'string')
data.choices[i] = {"text": data.choices[i]};
data.choices[i].text = core.replaceText(data.choices[i].text, prefix);
}
core.ui.drawChoices(core.replaceText(data.text, prefix), data.choices);
}
events.prototype._precompile_choices = function (data) {
if (!(data.choices instanceof Array)) return data;
@ -1952,25 +1971,16 @@ events.prototype._action_confirm = function (data, x, y, prefix) {
if (action.indexOf('choices:') == 0) {
var index = action.substring(8);
if (index == 'none' || ((index = parseInt(index)) >= 0) && index % 100 < 2) {
if (index != 'none') {
var timeout = Math.floor(index / 100) || 0;
core.setFlag('timeout', timeout);
index %= 100;
} else core.setFlag('timeout', 0);
core.status.event.selection = index;
setTimeout(function () {
core.status.route.push("choices:"+index);
if (index != 'none') {
if (index == 0) core.insertAction(data.yes);
else core.insertAction(data.no);
}
core.doAction();
}, core.status.replay.speed == 24 ? 1 : 750 / Math.max(1, core.status.replay.speed));
}
this.__action_confirm_replaying(data, index);
} else {
core.control._replay_error(action);
return;
}
} else {
// 录像中未记录选了哪个,则选默认值,而不是直接报错
core.status.replay.toReplay.unshift(action);
this.__action_confirm_replaying(data, data["default"] ? 0 : 1);
}
}
else {
core.status.event.selection = data["default"] ? 0 : 1;
@ -1986,6 +1996,23 @@ events.prototype._action_confirm = function (data, x, y, prefix) {
core.ui.drawConfirmBox(data.text);
}
events.prototype.__action_confirm_replaying = function (data, index) {
if (index != 'none') {
var timeout = Math.floor(index / 100) || 0;
core.setFlag('timeout', timeout);
index %= 100;
} else core.setFlag('timeout', 0);
core.status.event.selection = index;
setTimeout(function () {
core.status.route.push("choices:"+index);
if (index != 'none') {
if (index == 0) core.insertAction(data.yes);
else core.insertAction(data.no);
}
core.doAction();
}, core.status.replay.speed == 24 ? 1 : 750 / Math.max(1, core.status.replay.speed));
}
events.prototype._precompile_confirm = function (data) {
data.yes = this.precompile(data.yes);
data.no = this.precompile(data.no);