全局商店优化
This commit is contained in:
parent
5c2caf7556
commit
4081d7a3e7
@ -1084,7 +1084,12 @@ actions.prototype._clickAction = function (x, y, px, py) {
|
|||||||
var timeout = Math.max(0, core.status.event.timeout - new Date().getTime()) || 0;
|
var timeout = Math.max(0, core.status.event.timeout - new Date().getTime()) || 0;
|
||||||
delete core.status.event.timeout;
|
delete core.status.event.timeout;
|
||||||
core.setFlag('timeout', timeout);
|
core.setFlag('timeout', timeout);
|
||||||
core.status.route.push("choices:" + (100 * timeout + y - topIndex));
|
// 对全局商店特殊处理
|
||||||
|
var index = y - topIndex;
|
||||||
|
if (index == choices.length - 1 && core.hasFlag('@temp@shop')) {
|
||||||
|
index = -1;
|
||||||
|
}
|
||||||
|
core.status.route.push("choices:" + (100 * timeout + index));
|
||||||
core.insertAction(choice.action);
|
core.insertAction(choice.action);
|
||||||
core.doAction();
|
core.doAction();
|
||||||
}
|
}
|
||||||
|
|||||||
@ -2037,9 +2037,7 @@ events.prototype._action_choices = function (data, x, y, prefix) {
|
|||||||
var action = core.status.replay.toReplay.shift();
|
var action = core.status.replay.toReplay.shift();
|
||||||
if (action.indexOf('choices:') == 0 && !(action == 'choices:none' && !data.timeout)) {
|
if (action.indexOf('choices:') == 0 && !(action == 'choices:none' && !data.timeout)) {
|
||||||
var index = action.substring(8);
|
var index = action.substring(8);
|
||||||
if (index == 'none' || ((index = parseInt(index)) >= 0) && index % 100 < data.choices.length) {
|
if (!this.__action_choices_replaying(data, index)) {
|
||||||
this.__action_choices_replaying(data, index);
|
|
||||||
} else {
|
|
||||||
core.control._replay_error(action);
|
core.control._replay_error(action);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -2057,7 +2055,7 @@ events.prototype._action_choices = function (data, x, y, prefix) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (action != 'choices:none') core.status.replay.toReplay.unshift(action); // 首先归还刚才读出的下一步操作
|
if (action != 'choices:none') core.status.replay.toReplay.unshift(action); // 首先归还刚才读出的下一步操作
|
||||||
core.events.__action_choices_replaying(data, core.clamp(parseInt(value), 0, data.choices.length - 1))
|
core.events.__action_choices_replaying(data, ((parseInt(value) || 0) + data.choices.length) % data.choices.length);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -2080,17 +2078,24 @@ events.prototype._action_choices = function (data, x, y, prefix) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
events.prototype.__action_choices_replaying = function (data, index) {
|
events.prototype.__action_choices_replaying = function (data, index) {
|
||||||
|
var selection = index;
|
||||||
if (index != 'none') {
|
if (index != 'none') {
|
||||||
var timeout = Math.floor(index / 100) || 0;
|
selection = parseInt(index);
|
||||||
|
if (isNaN(selection)) return false;
|
||||||
|
if (selection < 0) selection += data.choices.length;
|
||||||
|
if (selection < 0) return false;
|
||||||
|
if (selection % 100 > 50) selection += data.choices.length;
|
||||||
|
if (selection % 100 > data.choices.length) return false;
|
||||||
|
var timeout = Math.floor(selection / 100) || 0;
|
||||||
core.setFlag('timeout', timeout);
|
core.setFlag('timeout', timeout);
|
||||||
index %= 100;
|
selection %= 100;
|
||||||
} else core.setFlag('timeout', 0);
|
} else core.setFlag('timeout', 0);
|
||||||
core.status.event.selection = index;
|
core.status.event.selection = selection;
|
||||||
setTimeout(function () {
|
setTimeout(function () {
|
||||||
core.status.route.push("choices:"+index);
|
core.status.route.push("choices:"+index);
|
||||||
if (index != 'none') {
|
if (selection != 'none') {
|
||||||
// 检查
|
// 检查
|
||||||
var choice = data.choices[index];
|
var choice = data.choices[selection];
|
||||||
if (choice.need != null && choice.need != '' && !core.calValue(choice.need)) {
|
if (choice.need != null && choice.need != '' && !core.calValue(choice.need)) {
|
||||||
// 无法选择此项
|
// 无法选择此项
|
||||||
core.control._replay_error("无法选择项:"+index);
|
core.control._replay_error("无法选择项:"+index);
|
||||||
@ -2101,6 +2106,7 @@ events.prototype.__action_choices_replaying = function (data, index) {
|
|||||||
}
|
}
|
||||||
core.doAction();
|
core.doAction();
|
||||||
}, core.status.replay.speed == 24 ? 1 : 750 / Math.max(1, core.status.replay.speed));
|
}, core.status.replay.speed == 24 ? 1 : 750 / Math.max(1, core.status.replay.speed));
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
events.prototype._precompile_choices = function (data) {
|
events.prototype._precompile_choices = function (data) {
|
||||||
|
|||||||
@ -677,8 +677,14 @@ utils.prototype.decodeRoute = function (route) {
|
|||||||
|
|
||||||
utils.prototype._decodeRoute_getNumber = function (decodeObj, noparse) {
|
utils.prototype._decodeRoute_getNumber = function (decodeObj, noparse) {
|
||||||
var num = "";
|
var num = "";
|
||||||
while (decodeObj.index < decodeObj.route.length && !isNaN(decodeObj.route.charAt(decodeObj.index))) {
|
var first = true;
|
||||||
num += decodeObj.route.charAt(decodeObj.index++);
|
while (true) {
|
||||||
|
var ch = decodeObj.route.charAt(decodeObj.index);
|
||||||
|
if (ch >= '0' && ch <= '9') num += ch;
|
||||||
|
else if (ch == '-' && first) num += ch;
|
||||||
|
else break;
|
||||||
|
first = false;
|
||||||
|
decodeObj.index++;
|
||||||
}
|
}
|
||||||
if (num.length == 0) num = "1";
|
if (num.length == 0) num = "1";
|
||||||
return noparse ? num : parseInt(num);
|
return noparse ? num : parseInt(num);
|
||||||
|
|||||||
@ -441,7 +441,10 @@ main.floors.sample1=
|
|||||||
}
|
}
|
||||||
],
|
],
|
||||||
"false": [
|
"false": [
|
||||||
"\t[老人,trader]你的金钱不足!"
|
"\t[老人,trader]你的金钱不足!",
|
||||||
|
{
|
||||||
|
"type": "continue"
|
||||||
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
@ -464,13 +467,13 @@ main.floors.sample1=
|
|||||||
"name": "item:blueKey",
|
"name": "item:blueKey",
|
||||||
"operator": "+=",
|
"operator": "+=",
|
||||||
"value": "1"
|
"value": "1"
|
||||||
},
|
|
||||||
{
|
|
||||||
"type": "continue"
|
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"false": [
|
"false": [
|
||||||
"\t[老人,trader]你的金钱不足!"
|
"\t[老人,trader]你的金钱不足!",
|
||||||
|
{
|
||||||
|
"type": "continue"
|
||||||
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|||||||
@ -112,6 +112,8 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 =
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_shouldProcessKeyUp = true;
|
||||||
|
|
||||||
// Step 4: 执行标准公共商店
|
// Step 4: 执行标准公共商店
|
||||||
core.insertAction(this._convertShop(shop));
|
core.insertAction(this._convertShop(shop));
|
||||||
return true;
|
return true;
|
||||||
@ -221,9 +223,16 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 =
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var _shouldProcessKeyUp = true;
|
||||||
|
|
||||||
/// 允许商店X键退出
|
/// 允许商店X键退出
|
||||||
core.registerAction('keyUp', 'shops', function (keycode) {
|
core.registerAction('keyUp', 'shops', function (keycode) {
|
||||||
if (!core.status.lockControl || !core.hasFlag("@temp@shop") || core.status.event.id != 'action') return false;
|
if (!core.status.lockControl || !core.hasFlag("@temp@shop") || core.status.event.id != 'action') return false;
|
||||||
|
if ((keycode == 13 || keycode == 32) && !_shouldProcessKeyUp) {
|
||||||
|
_shouldProcessKeyUp = true;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
if (core.status.event.data.type != 'choices') return false;
|
if (core.status.event.data.type != 'choices') return false;
|
||||||
var data = core.status.event.data.current;
|
var data = core.status.event.data.current;
|
||||||
var choices = data.choices;
|
var choices = data.choices;
|
||||||
@ -232,7 +241,6 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 =
|
|||||||
core.actions._clickAction(core.actions.HSIZE, topIndex + choices.length - 1);
|
core.actions._clickAction(core.actions.HSIZE, topIndex + choices.length - 1);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (keycode == 13 || keycode == 32) return true;
|
|
||||||
return false;
|
return false;
|
||||||
}, 60);
|
}, 60);
|
||||||
|
|
||||||
@ -245,6 +253,7 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 =
|
|||||||
var topIndex = core.actions._getChoicesTopIndex(choices.length);
|
var topIndex = core.actions._getChoicesTopIndex(choices.length);
|
||||||
if (keycode == 13 || keycode == 32) { // Space, Enter
|
if (keycode == 13 || keycode == 32) { // Space, Enter
|
||||||
core.actions._clickAction(core.actions.HSIZE, topIndex + core.status.event.selection);
|
core.actions._clickAction(core.actions.HSIZE, topIndex + core.status.event.selection);
|
||||||
|
_shouldProcessKeyUp = false;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user