全键盘操作

This commit is contained in:
ckcz123 2017-12-26 17:32:37 +08:00
parent 92c4a2e84d
commit 795239934f
4 changed files with 67 additions and 41 deletions

View File

@ -499,11 +499,8 @@ core.prototype.keyUp = function(keyCode) {
if (core.status.lockControl) { if (core.status.lockControl) {
core.status.holdingKeys = []; core.status.holdingKeys = [];
// 全键盘操作部分 // 全键盘操作部分
if (core.status.event.id == 'text' && (keyCode==13 || keyCode==32)) { if (core.status.event.id == 'text' && (keyCode==13 || keyCode==32 || keyCode==67)) {
core.drawText(); core.drawText();
return; return;
} }
@ -515,7 +512,7 @@ core.prototype.keyUp = function(keyCode) {
core.events.keyUpAction(keyCode); core.events.keyUpAction(keyCode);
return; return;
} }
if (core.status.event.id=='about' && (keyCode==13 || keyCode==32)) { if (core.status.event.id=='about' && (keyCode==13 || keyCode==32 || keyCode==67)) {
core.events.clickAbout(); core.events.clickAbout();
return; return;
} }
@ -598,6 +595,10 @@ core.prototype.keyUp = function(keyCode) {
if (!core.status.lockControl && core.status.heroStop) if (!core.status.lockControl && core.status.heroStop)
core.getNextItem(); core.getNextItem();
break; break;
case 72: // H
if (!core.status.lockControl && core.status.heroStop)
core.ui.drawHelp();
break;
case 37: // UP case 37: // UP
break; break;
case 38: // DOWN case 38: // DOWN

View File

@ -645,7 +645,7 @@ events.prototype.keyUpConfirmBox = function (keycode) {
core.ui.drawConfirmBox(core.status.event.ui, core.status.event.data.yes, core.status.event.data.no); core.ui.drawConfirmBox(core.status.event.ui, core.status.event.data.yes, core.status.event.data.no);
} }
if (keycode==13 || keycode==32) { if (keycode==13 || keycode==32 || keycode==67) {
if (core.status.event.selection==0 && core.isset(core.status.event.data.yes)) { if (core.status.event.selection==0 && core.isset(core.status.event.data.yes)) {
core.status.event.selection=null; core.status.event.selection=null;
core.status.event.data.yes(); core.status.event.data.yes();
@ -706,7 +706,7 @@ events.prototype.keyDownAction = function (keycode) {
} }
events.prototype.keyUpAction = function (keycode) { events.prototype.keyUpAction = function (keycode) {
if (core.status.event.data.type=='text' && (keycode==13 || keycode==32)) { if (core.status.event.data.type=='text' && (keycode==13 || keycode==32 || keycode==67)) {
this.doAction(); this.doAction();
return; return;
} }
@ -714,7 +714,7 @@ events.prototype.keyUpAction = function (keycode) {
var data = core.status.event.data.current; var data = core.status.event.data.current;
var choices = data.choices; var choices = data.choices;
if (choices.length>0) { if (choices.length>0) {
if (keycode==13 || keycode==32) { if (keycode==13 || keycode==32 || keycode==67) {
this.insertAction(choices[core.status.event.selection].action); this.insertAction(choices[core.status.event.selection].action);
this.doAction(); this.doAction();
} }
@ -745,6 +745,13 @@ events.prototype.keyDownBook = function (keycode) {
return; return;
} }
events.prototype.keyUpBook = function (keycode) {
if (keycode==27 || keycode==88) {
core.ui.closePanel(true);
return;
}
}
// 飞行器 // 飞行器
events.prototype.clickFly = function(x,y) { events.prototype.clickFly = function(x,y) {
if ((x==10 || x==11) && y==9) core.ui.drawFly(core.status.event.data-1); if ((x==10 || x==11) && y==9) core.ui.drawFly(core.status.event.data-1);
@ -767,20 +774,13 @@ events.prototype.keyDownFly = function (keycode) {
} }
events.prototype.keyUpFly = function (keycode) { events.prototype.keyUpFly = function (keycode) {
if (keycode==71 || keycode==27) if (keycode==71 || keycode==27 || keycode==88)
core.ui.closePanel(); core.ui.closePanel();
if (keycode==13 || keycode==32) if (keycode==13 || keycode==32 || keycode==67)
this.clickFly(5,5); this.clickFly(5,5);
return; return;
} }
events.prototype.keyUpBook = function (keycode) {
if (keycode==27 || keycode==88) {
core.ui.closePanel(true);
return;
}
}
// 商店 // 商店
events.prototype.clickShop = function(x,y) { events.prototype.clickShop = function(x,y) {
var shop = core.status.event.data.shop; var shop = core.status.event.data.shop;
@ -849,7 +849,7 @@ events.prototype.keyDownShop = function (keycode) {
} }
events.prototype.keyUpShop = function (keycode) { events.prototype.keyUpShop = function (keycode) {
if (keycode==27) { if (keycode==27 || keycode==88) {
if (core.status.event.data.fromList) { if (core.status.event.data.fromList) {
core.status.boxAnimateObjs = []; core.status.boxAnimateObjs = [];
core.setBoxAnimate(); core.setBoxAnimate();
@ -861,7 +861,7 @@ events.prototype.keyUpShop = function (keycode) {
} }
var shop = core.status.event.data.shop; var shop = core.status.event.data.shop;
var choices = shop.choices; var choices = shop.choices;
if (keycode==13 || keycode==32) { if (keycode==13 || keycode==32 || keycode==67) {
var topIndex = 6 - parseInt(choices.length / 2); var topIndex = 6 - parseInt(choices.length / 2);
this.clickShop(6, topIndex+core.status.event.selection); this.clickShop(6, topIndex+core.status.event.selection);
} }
@ -904,12 +904,12 @@ events.prototype.keyDownQuickShop = function (keycode) {
} }
events.prototype.keyUpQuickShop = function (keycode) { events.prototype.keyUpQuickShop = function (keycode) {
if (keycode==27 || keycode==75) { if (keycode==27 || keycode==75 || keycode==88) {
core.ui.closePanel(); core.ui.closePanel();
return; return;
} }
var shopList = core.status.shops, keys = Object.keys(shopList); var shopList = core.status.shops, keys = Object.keys(shopList);
if (keycode==13 || keycode==32) { if (keycode==13 || keycode==32 || keycode==67) {
var topIndex = 6 - parseInt(keys.length / 2); var topIndex = 6 - parseInt(keys.length / 2);
this.clickQuickShop(6, topIndex+core.status.event.selection); this.clickQuickShop(6, topIndex+core.status.event.selection);
} }
@ -1014,13 +1014,13 @@ events.prototype.keyDownToolbox = function (keycode) {
} }
events.prototype.keyUpToolbox = function (keycode) { events.prototype.keyUpToolbox = function (keycode) {
if (keycode==84 || keycode==27) { if (keycode==84 || keycode==27 || keycode==88) {
core.ui.closePanel(); core.ui.closePanel();
return; return;
} }
if (!core.isset(core.status.event.data)) return; if (!core.isset(core.status.event.data)) return;
if (keycode==13 || keycode==32) { if (keycode==13 || keycode==32 || keycode==67) {
this.clickToolboxIndex(core.status.event.selection); this.clickToolboxIndex(core.status.event.selection);
return; return;
} }
@ -1065,8 +1065,7 @@ events.prototype.keyDownSL = function(keycode) {
return; return;
} }
if (keycode==38) { // up if (keycode==38) { // up
if ((core.status.event.data-1)%6>=3) core.ui.drawSLPanel(core.status.event.data - 3);
core.ui.drawSLPanel(core.status.event.data - 3);
return; return;
} }
if (keycode==39) { // right if (keycode==39) { // right
@ -1074,8 +1073,7 @@ events.prototype.keyDownSL = function(keycode) {
return; return;
} }
if (keycode==40) { // down if (keycode==40) { // down
if ((core.status.event.data-1)%6<3) core.ui.drawSLPanel(core.status.event.data + 3);
core.ui.drawSLPanel(core.status.event.data + 3);
return; return;
} }
if (keycode==33) { // PAGEUP if (keycode==33) { // PAGEUP
@ -1089,14 +1087,14 @@ events.prototype.keyDownSL = function(keycode) {
} }
events.prototype.keyUpSL = function (keycode) { events.prototype.keyUpSL = function (keycode) {
if (keycode==27 || (core.status.event.id == 'save' && keycode==83) || (core.status.event.id == 'load' && keycode==68)) { if (keycode==27 || keycode==88 || (core.status.event.id == 'save' && keycode==83) || (core.status.event.id == 'load' && keycode==68)) {
core.ui.closePanel(); core.ui.closePanel();
if (!core.isPlaying()) { if (!core.isPlaying()) {
core.showStartAnimate(); core.showStartAnimate();
} }
return; return;
} }
if (keycode==13 || keycode==32) { if (keycode==13 || keycode==32 || keycode==67) {
core.doSL(core.status.event.data, core.status.event.id); core.doSL(core.status.event.data, core.status.event.id);
return; return;
} }
@ -1159,7 +1157,7 @@ events.prototype.keyDownSwitchs = function (keycode) {
} }
events.prototype.keyUpSwitchs = function (keycode) { events.prototype.keyUpSwitchs = function (keycode) {
if (keycode==27) { if (keycode==27 || keycode==88) {
core.status.event.selection=0; core.status.event.selection=0;
core.ui.drawSettings(false); core.ui.drawSettings(false);
return; return;
@ -1167,7 +1165,7 @@ events.prototype.keyUpSwitchs = function (keycode) {
var choices = [ var choices = [
"背景音乐", "战斗动画", "怪物显伤", "领域显伤", "返回主菜单" "背景音乐", "战斗动画", "怪物显伤", "领域显伤", "返回主菜单"
]; ];
if (keycode==13 || keycode==32) { if (keycode==13 || keycode==32 || keycode==67) {
var topIndex = 6 - parseInt((choices.length - 1) / 2); var topIndex = 6 - parseInt((choices.length - 1) / 2);
this.clickSwitchs(6, topIndex+core.status.event.selection); this.clickSwitchs(6, topIndex+core.status.event.selection);
} }
@ -1178,7 +1176,7 @@ events.prototype.keyUpSwitchs = function (keycode) {
events.prototype.clickSettings = function (x,y) { events.prototype.clickSettings = function (x,y) {
if (x<5 || x>7) return; if (x<5 || x>7) return;
var choices = [ var choices = [
"系统设置", "快捷商店", "同步存档", "重新开始", "关于本塔", "返回游戏" "系统设置", "快捷商店", "同步存档", "重新开始", "操作帮助", "关于本塔", "返回游戏"
]; ];
var topIndex = 6 - parseInt((choices.length - 1) / 2); var topIndex = 6 - parseInt((choices.length - 1) / 2);
if (y>=topIndex && y<topIndex+choices.length) { if (y>=topIndex && y<topIndex+choices.length) {
@ -1208,12 +1206,14 @@ events.prototype.clickSettings = function (x,y) {
}); });
break; break;
case 4: case 4:
core.ui.drawAbout(); core.ui.drawHelp();
break; break;
case 5: case 5:
core.ui.drawAbout();
break;
case 6:
core.ui.closePanel(); core.ui.closePanel();
break; break;
} }
} }
return; return;
@ -1221,7 +1221,7 @@ events.prototype.clickSettings = function (x,y) {
events.prototype.keyDownSettings = function (keycode) { events.prototype.keyDownSettings = function (keycode) {
var choices = [ var choices = [
"系统设置", "快捷商店", "同步存档", "重新开始", "关于本塔", "返回游戏" "系统设置", "快捷商店", "同步存档", "重新开始", "操作帮助", "关于本塔", "返回游戏"
]; ];
if (keycode==38) { if (keycode==38) {
core.status.event.selection--; core.status.event.selection--;
@ -1236,14 +1236,14 @@ events.prototype.keyDownSettings = function (keycode) {
} }
events.prototype.keyUpSettings = function (keycode) { events.prototype.keyUpSettings = function (keycode) {
if (keycode==27) { if (keycode==27 || keycode==88) {
core.ui.closePanel(); core.ui.closePanel();
return; return;
} }
var choices = [ var choices = [
"系统设置", "快捷商店", "同步存档", "重新开始", "关于本塔", "返回游戏" "系统设置", "快捷商店", "同步存档", "重新开始", "操作帮助", "关于本塔", "返回游戏"
]; ];
if (keycode==13 || keycode==32) { if (keycode==13 || keycode==32 || keycode==67) {
var topIndex = 6 - parseInt((choices.length - 1) / 2); var topIndex = 6 - parseInt((choices.length - 1) / 2);
this.clickSettings(6, topIndex+core.status.event.selection); this.clickSettings(6, topIndex+core.status.event.selection);
} }
@ -1301,7 +1301,7 @@ events.prototype.keyDownSyncSave = function (keycode) {
} }
events.prototype.keyUpSyncSave = function (keycode) { events.prototype.keyUpSyncSave = function (keycode) {
if (keycode==27) { if (keycode==27 || keycode==88) {
core.status.event.selection=2; core.status.event.selection=2;
core.ui.drawSettings(false); core.ui.drawSettings(false);
return; return;
@ -1309,7 +1309,7 @@ events.prototype.keyUpSyncSave = function (keycode) {
var choices = [ var choices = [
"同步存档到服务器", "从服务器加载存档", "清空本地存档", "返回主菜单" "同步存档到服务器", "从服务器加载存档", "清空本地存档", "返回主菜单"
]; ];
if (keycode==13 || keycode==32) { if (keycode==13 || keycode==32 || keycode==67) {
var topIndex = 6 - parseInt((choices.length - 1) / 2); var topIndex = 6 - parseInt((choices.length - 1) / 2);
this.clickSyncSave(6, topIndex+core.status.event.selection); this.clickSyncSave(6, topIndex+core.status.event.selection);
} }

View File

@ -353,7 +353,7 @@ ui.prototype.drawSettings = function (need) {
return; return;
this.drawChoices(null, [ this.drawChoices(null, [
"系统设置", "快捷商店", "同步存档", "重新开始", "关于本塔", "返回游戏" "系统设置", "快捷商店", "同步存档", "重新开始", "操作帮助", "关于本塔", "返回游戏"
]); ]);
} }
@ -1101,4 +1101,28 @@ ui.prototype.drawAbout = function() {
core.fillText('ui', '打Dota的喵', text_start+len, top+272); core.fillText('ui', '打Dota的喵', text_start+len, top+272);
core.fillText('ui', 'HTML5魔塔交流群539113091', text_start, top+304); core.fillText('ui', 'HTML5魔塔交流群539113091', text_start, top+304);
*/ */
}
ui.prototype.drawHelp = function () {
core.drawText([
"\t[键盘快捷键列表]"+
"[CTRL] 跳过对话\n" +
"[X] 打开/关闭怪物手册\n" +
"[G] 打开/关闭楼层传送器\n" +
"[S/D] 打开/关闭存/读档页面\n" +
"[K] 打开/关闭快捷商店选择列表\n" +
"[T] 打开/关闭工具栏\n" +
"[ESC] 打开/关闭系统菜单\n" +
"[H] 打开帮助页面\n"+
"[SPACE] 轻按(仅在轻按开关打开时有效)\n" +
"[1] 快捷使用破墙镐\n" +
"[2] 快捷使用炸弹/圣锤\n" +
"[3] 快捷使用中心对称飞行器",
"\t[鼠标操作]"+
"点状态栏中图标: 进行对应的操作\n"+
"点任意块: 寻路并移动\n"+
"点任意块并拖动: 指定寻路路线\n"+
"单击勇士: 转向\n"+
"双击勇士: 轻按(仅在轻按开关打开时有效)"
]);
} }

View File

@ -10,6 +10,7 @@
[K] 打开/关闭快捷商店选择列表 [K] 打开/关闭快捷商店选择列表
[T] 打开/关闭工具栏 [T] 打开/关闭工具栏
[ESC] 打开/关闭系统菜单 [ESC] 打开/关闭系统菜单
[H] 打开帮助页面
[SPACE] 轻按(仅在轻按开关打开时有效) [SPACE] 轻按(仅在轻按开关打开时有效)
[1] 快捷使用破墙镐 [1] 快捷使用破墙镐
[2] 快捷使用炸弹/圣锤(先检测有没有炸弹,没有再检测圣锤) [2] 快捷使用炸弹/圣锤(先检测有没有炸弹,没有再检测圣锤)