setGlobal & getGlobal
This commit is contained in:
parent
efe51ce363
commit
8769668222
@ -1300,6 +1300,7 @@ control.prototype._replay_save = function () {
|
||||
}
|
||||
|
||||
control.prototype._replay_error = function (action) {
|
||||
core.ui.closePanel();
|
||||
core.status.replay.replaying = false;
|
||||
var len = core.status.replay.toReplay.length;
|
||||
var prevList = core.status.replay.totalList.slice(-len - 11, -len - 1);
|
||||
@ -1427,8 +1428,7 @@ control.prototype._replayAction_shop = function (action) {
|
||||
var shopInterval = setInterval(function () {
|
||||
if (!core.actions._clickShop(core.__HALF_SIZE__, topIndex+core.status.event.selection)) {
|
||||
clearInterval(shopInterval);
|
||||
core.stopReplay();
|
||||
core.drawTip("录像文件出错");
|
||||
core.control._replay_error(action);
|
||||
return;
|
||||
}
|
||||
if (selections.length==0) {
|
||||
|
||||
@ -1336,10 +1336,8 @@ events.prototype.__action_getInput = function (hint, isText, callback) {
|
||||
callback(value);
|
||||
}
|
||||
catch (e) {
|
||||
main.log(e);
|
||||
core.stopReplay();
|
||||
core.insertAction(["录像文件出错,请在控制台查看报错信息。", {"type": "exit"}]);
|
||||
core.doAction();
|
||||
core.control._replay_error(action);
|
||||
return;
|
||||
}
|
||||
}
|
||||
else {
|
||||
@ -1384,10 +1382,7 @@ events.prototype._action_choices = function (data, x, y, prefix) {
|
||||
}, 750 / Math.max(1, core.status.replay.speed))
|
||||
}
|
||||
else {
|
||||
main.log("录像文件出错!当前需要一个 choices: 项,实际为 " + action);
|
||||
core.stopReplay();
|
||||
core.insertAction(["录像文件出错,请在控制台查看报错信息。", {"type": "exit"}]);
|
||||
core.doAction();
|
||||
core.control._replay_error(action);
|
||||
return;
|
||||
}
|
||||
}
|
||||
@ -1410,10 +1405,7 @@ events.prototype._action_confirm = function (data, x, y, prefix) {
|
||||
}, 750 / Math.max(1, core.status.replay.speed))
|
||||
}
|
||||
else {
|
||||
main.log("录像文件出错!当前需要一个 choices: 项,实际为 " + action);
|
||||
core.stopReplay();
|
||||
core.insertAction(["录像文件出错,请在控制台查看报错信息。", {"type": "exit"}]);
|
||||
core.doAction();
|
||||
core.control._replay_error(action);
|
||||
return;
|
||||
}
|
||||
}
|
||||
@ -1827,7 +1819,7 @@ events.prototype._setValue_setSwitch = function (name, value, prefix) {
|
||||
|
||||
events.prototype._setValue_setGlobal = function (name, value) {
|
||||
if (name.indexOf("global:") !== 0) return;
|
||||
core.setLocalStorage(name.substring(7), value);
|
||||
core.setGlobal(name.substring(7), value);
|
||||
}
|
||||
|
||||
////// 数值增减 //////
|
||||
|
||||
@ -67,7 +67,7 @@ utils.prototype.calValue = function (value, prefix, need, times) {
|
||||
value = value.replace(/item:([a-zA-Z0-9_]+)/g, "core.itemCount('$1')");
|
||||
value = value.replace(/flag:([a-zA-Z0-9_\u4E00-\u9FCC]+)/g, "core.getFlag('$1', 0)");
|
||||
value = value.replace(/switch:([a-zA-Z0-9_]+)/g, "core.getFlag('" + (prefix || ":f@x@y") + "@$1', 0)");
|
||||
value = value.replace(/global:([a-zA-Z0-9_\u4E00-\u9FCC]+)/g, "core.getLocalStorage('$1', 0)");
|
||||
value = value.replace(/global:([a-zA-Z0-9_\u4E00-\u9FCC]+)/g, "core.getGlobal('$1', 0)");
|
||||
return eval(value);
|
||||
}
|
||||
if (value instanceof Function) {
|
||||
@ -247,6 +247,31 @@ utils.prototype.removeLocalForage = function (key, successCallback, errorCallbac
|
||||
})
|
||||
}
|
||||
|
||||
utils.prototype.setGlobal = function (key, value) {
|
||||
if (core.status.replay.replaying) return;
|
||||
core.setLocalStorage(key, value);
|
||||
}
|
||||
|
||||
utils.prototype.getGlobal = function (key, defaultValue) {
|
||||
var value;
|
||||
if (core.isReplaying()) {
|
||||
// 不考虑key不一致的情况
|
||||
var action = core.status.replay.toReplay.shift();
|
||||
if (action.indexOf("input2:") == 0) {
|
||||
value = JSON.parse(core.decodeBase64(action.substring(7)));
|
||||
}
|
||||
else {
|
||||
core.control._replay_error(action);
|
||||
return defaultValue;
|
||||
}
|
||||
}
|
||||
else {
|
||||
value = core.getLocalStorage(key, defaultValue);
|
||||
}
|
||||
core.status.route.push("input2:" + core.encodeBase64(JSON.stringify(value)));
|
||||
return value;
|
||||
}
|
||||
|
||||
////// 深拷贝一个对象 //////
|
||||
utils.prototype.clone = function (data, filter, recursion) {
|
||||
if (!core.isset(data)) return null;
|
||||
@ -687,9 +712,8 @@ utils.prototype.rand2 = function (num) {
|
||||
value = parseInt(action.substring(7));
|
||||
}
|
||||
else {
|
||||
core.stopReplay();
|
||||
core.drawTip("录像文件出错");
|
||||
return;
|
||||
core.control._replay_error(action);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
else {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user