/* actions.js:用户交互的事件的处理 键盘、鼠标、触摸屏事件相关 */ function actions() { this.init(); } actions.prototype.init = function () { } ////// 按下某个键时 ////// actions.prototype.onkeyDown = function (e) { if (core.isset(core.status.replay)&&core.status.replay.replaying&&core.status.event.id!='save'&&(core.status.event.id||"").indexOf('book')!=0) return; if (!core.isset(core.status.holdingKeys))core.status.holdingKeys=[]; var isArrow={37:true,38:true,39:true,40:true}[e.keyCode] if(isArrow && !core.status.lockControl){ for(var ii =0;iimax){ index=ii; max=directionDistance[ii]; } } pos=[{'x':0,'y':1},{'x':-1,'y':0},{'x':0,'y':-1},{'x':1,'y':0},false][index] if(pos){ pos.x+=pos0.x; pos.y+=pos0.y; core.status.stepPostfix.push(pos); core.fillPosWithPoint(pos); } } ////// 当点击(触摸)事件放开时 ////// actions.prototype.onup = function () { if (core.isset(core.status.replay)&&core.status.replay.replaying&&core.status.event.id!='save'&&(core.status.event.id||"").indexOf('book')!=0) return; clearTimeout(core.timeout.onDownTimeout); core.timeout.onDownTimeout = null; clearInterval(core.interval.onDownInterval); core.interval.onDownInterval = null; // core.status.holdingPath=0; if(core.status.stepPostfix.length>0){ var stepPostfix = []; var direction={'0':{'1':'down','-1':'up'},'-1':{'0':'left'},'1':{'0':'right'}}; for(var ii=1;ii=1000) { core.waitHeroToStop(function () { // 绘制快捷键 core.ui.drawKeyBoard(); }); } else { //posx,posy是寻路的目标点,stepPostfix是后续的移动 this.onclick(posx,posy,stepPostfix); } core.status.downTime=null; } } ////// 获得点击事件相对左上角的坐标(0到12之间) ////// actions.prototype.getClickLoc = function (x, y) { var statusBar = {'x': 0, 'y': 0}; var size = 32; size = size * core.domStyle.scale; switch (core.domStyle.screenMode) {// 这里的3是指statusBar和游戏画布之间的白线宽度 case 'vertical': statusBar.x = 0; statusBar.y = core.dom.statusBar.offsetHeight + 3; break; case 'horizontal': case 'bigScreen': statusBar.x = core.dom.statusBar.offsetWidth + 3; statusBar.y = 0; break; } var left = core.dom.gameGroup.offsetLeft + statusBar.x; var top = core.dom.gameGroup.offsetTop + statusBar.y; var loc={'x': x - left, 'y': y - top, 'size': size}; return loc; } ////// 具体点击屏幕上(x,y)点时,执行的操作 ////// actions.prototype.onclick = function (x, y, stepPostfix) { if (core.isset(core.status.replay)&&core.status.replay.replaying&&core.status.event.id!='save'&&(core.status.event.id||"").indexOf('book')!=0) return; // console.log("Click: (" + x + "," + y + ")"); stepPostfix=stepPostfix||[]; // 非游戏屏幕内 if (x<0 || y<0 || x>12 || y>12) return; // 中心对称飞行器 if (core.status.usingCenterFly) { if (x!=12-core.getHeroLoc('x') || y!=12-core.getHeroLoc('y')) { core.clearMap('ui', (12-core.getHeroLoc('x'))*32,(12-core.getHeroLoc('y'))*32,32,32); } else { if (core.canUseItem('centerFly')) { core.useItem('centerFly'); core.clearMap('ui', core.getHeroLoc('x')*32,core.getHeroLoc('y')*32,32,32); return; } else { core.drawTip('当前不能使用中心对称飞行器'); core.clearMap('ui', (12-core.getHeroLoc('x'))*32,(12-core.getHeroLoc('y'))*32,32,32); } } core.status.usingCenterFly= false; } // 寻路 if (!core.status.lockControl) { core.setAutomaticRoute(x, y, stepPostfix); return; } // 怪物手册 if (core.status.event.id == 'book') { this.clickBook(x,y); return; } // 怪物详细信息 if (core.status.event.id == 'book-detail') { this.clickBookDetail(x,y); return; } // 楼层飞行器 if (core.status.event.id == 'fly') { this.clickFly(x,y); return; } // 查看地图 if (core.status.event.id == 'viewMaps') { this.clickViewMaps(x,y); return; } // 开关 if (core.status.event.id == 'switchs') { this.clickSwitchs(x,y); return; } // 设置 if (core.status.event.id == 'settings') { this.clickSettings(x,y); return; } // 商店 if (core.status.event.id == 'shop') { this.clickShop(x,y); return; } // 快捷商店 if (core.status.event.id == 'selectShop') { this.clickQuickShop(x,y); return; } // 工具栏 if (core.status.event.id == 'toolbox') { this.clickToolbox(x,y); return; } // 存读档 if (core.status.event.id == 'save' || core.status.event.id == 'load' || core.status.event.id=='replayLoad') { this.clickSL(x,y); return; } // 选项 if (core.status.event.id == 'confirmBox') { this.clickConfirmBox(x,y); return; } if (core.status.event.id == 'keyBoard') { this.clickKeyBoard(x,y); return; } // 关于 if (core.status.event.id == 'about') { this.clickAbout(x,y); return; } if (core.status.event.id == 'action') { this.clickAction(x,y); return; } // 纯文本 if (core.status.event.id == 'text') { core.drawText(); return; } // 同步存档 if (core.status.event.id == 'syncSave') { this.clickSyncSave(x,y); return; } if (core.status.event.id == 'syncSelect') { this.clickSyncSelect(x,y); return; } if (core.status.event.id == 'localSaveSelect') { this.clickLocalSaveSelect(x,y); return; } if (core.status.event.id=='storageRemove') { this.clickStorageRemove(x,y); return; } if (core.status.event.id == 'cursor') { this.clickCursor(x,y); return; } if (core.status.event.id == 'replay') { this.clickReplay(x,y); return; } } ////// 滑动鼠标滚轮时的操作 ////// actions.prototype.onmousewheel = function (direct) { if (core.isset(core.status.replay)&&core.status.replay.replaying&&core.status.event.id!='save'&&(core.status.event.id||"").indexOf('book')!=0) return; // 向下滚动是 -1 ,向上是 1 // 楼层飞行器 if (core.status.lockControl && core.status.event.id == 'fly') { if (direct==1) core.ui.drawFly(core.status.event.data+1); if (direct==-1) core.ui.drawFly(core.status.event.data-1); return; } // 怪物手册 if (core.status.lockControl && core.status.event.id == 'book') { if (direct==1) core.ui.drawBook(core.status.event.data - 6); if (direct==-1) core.ui.drawBook(core.status.event.data + 6); return; } // 存读档 if (core.status.lockControl && (core.status.event.id == 'save' || core.status.event.id == 'load')) { if (direct==1) core.ui.drawSLPanel(core.status.event.data - 10); if (direct==-1) core.ui.drawSLPanel(core.status.event.data + 10); return; } // 浏览地图 if (core.status.lockControl && core.status.event.id == 'viewMaps') { if (direct==1) this.clickViewMaps(6,2); if (direct==-1) this.clickViewMaps(6,10); return; } } /////////////////// 在某个界面时的按键点击效果 /////////////////// ////// 长按 ////// actions.prototype.longClick = function () { if (!core.isPlaying()) return false; if (core.status.event.id=='text') { core.drawText(); return true; } if (core.status.event.id=='action' && (core.status.event.data.type=='text' || core.status.event.data.type=='wait')) { core.doAction(); return true; } return false; } ////// 按下Ctrl键时(快捷跳过对话) ////// actions.prototype.keyDownCtrl = function () { if (core.status.event.id=='text') { core.drawText(); return; } if (core.status.event.id=='action' && (core.status.event.data.type=='text' || core.status.event.data.type=='wait')) { core.doAction(); return; } } ////// 点击确认框时 ////// actions.prototype.clickConfirmBox = function (x,y) { if ((x == 4 || x == 5) && y == 7 && core.isset(core.status.event.data.yes)) core.status.event.data.yes(); if ((x == 7 || x == 8) && y == 7 && core.isset(core.status.event.data.no)) core.status.event.data.no(); } ////// 键盘操作确认框时 ////// actions.prototype.keyUpConfirmBox = function (keycode) { if (keycode==37) { core.status.event.selection=0; core.ui.drawConfirmBox(core.status.event.ui, core.status.event.data.yes, core.status.event.data.no); } if (keycode==39) { core.status.event.selection=1; core.ui.drawConfirmBox(core.status.event.ui, core.status.event.data.yes, core.status.event.data.no); } if (keycode==13 || keycode==32 || keycode==67) { if (core.status.event.selection==0 && core.isset(core.status.event.data.yes)) { core.status.event.selection=null; core.status.event.data.yes(); } if (core.status.event.selection==1 && core.isset(core.status.event.data.no)) { core.status.event.selection=null; core.status.event.data.no(); } } } ////// 自定义事件时的点击操作 ////// actions.prototype.clickAction = function (x,y) { if (core.status.event.data.type=='text' || core.status.event.data.type=='wait') { // 文字 core.doAction(); return; } if (core.status.event.data.type=='choices') { // 选项 var data = core.status.event.data.current; var choices = data.choices; if (choices.length==0) return; if (x >= 5 && x <= 7) { var topIndex = 6 - parseInt((choices.length - 1) / 2); if (y>=topIndex && y0) { if (keycode==38) { core.status.event.selection--; core.ui.drawChoices(core.status.event.ui.text, core.status.event.ui.choices); } if (keycode==40) { core.status.event.selection++; core.ui.drawChoices(core.status.event.ui.text, core.status.event.ui.choices); } } } } ////// 自定义事件时,放开某个键的操作 ////// actions.prototype.keyUpAction = function (keycode) { if ((core.status.event.data.type=='text' || core.status.event.data.type=='wait') && (keycode==13 || keycode==32 || keycode==67)) { core.doAction(); return; } if (core.status.event.data.type=='choices') { var data = core.status.event.data.current; var choices = data.choices; if (choices.length>0) { if (keycode==13 || keycode==32 || keycode==67) { core.status.route.push("choices:"+core.status.event.selection); core.insertAction(choices[core.status.event.selection].action); core.doAction(); } } } } ////// 怪物手册界面的点击操作 ////// actions.prototype.clickBook = function(x,y) { // 上一页 if ((x == 3 || x == 4) && y == 12) { core.ui.drawBook(core.status.event.data - 6); return; } // 下一页 if ((x == 8 || x == 9) && y == 12) { core.ui.drawBook(core.status.event.data + 6); return; } // 返回 if (x>=10 && x<=12 && y==12) { if (core.status.event.selection==null) core.ui.closePanel(); else { core.status.boxAnimateObjs = []; core.ui.drawMaps(core.status.event.selection); } return; } // 怪物信息 var data = core.status.event.data; if (core.isset(data) && y<12) { var page=parseInt(data/6); var index=6*page+parseInt(y/2); core.ui.drawBook(index); core.ui.drawBookDetail(index); } return; } ////// 怪物手册界面时,按下某个键的操作 ////// actions.prototype.keyDownBook = function (keycode) { if (keycode==37) core.ui.drawBook(core.status.event.data-6); if (keycode==38) core.ui.drawBook(core.status.event.data-1); if (keycode==39) core.ui.drawBook(core.status.event.data+6); if (keycode==40) core.ui.drawBook(core.status.event.data+1); if (keycode==33) core.ui.drawBook(core.status.event.data-6); if (keycode==34) core.ui.drawBook(core.status.event.data+6); return; } ////// 怪物手册界面时,放开某个键的操作 ////// actions.prototype.keyUpBook = function (keycode) { if (keycode==27 || keycode==88) { if (core.status.event.selection==null) core.ui.closePanel(); else { core.status.boxAnimateObjs = []; core.ui.drawMaps(core.status.event.selection); } return; } if (keycode==13 || keycode==32 || keycode==67) { var data=core.status.event.data; if (core.isset(data)) { this.clickBook(6, 2*(data%6)); } return; } } ////// 怪物手册属性显示界面时的点击操作 ////// actions.prototype.clickBookDetail = function () { core.clearMap('data', 0, 0, 416, 416); core.status.event.id = 'book'; } ////// 楼层传送器界面时的点击操作 ////// actions.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==5) core.ui.drawFly(core.status.event.data+1); if (x>=5 && x<=7 && y==12) core.ui.closePanel(); if (x>=0 && x<=9 && y>=3 && y<=11) { var index=core.status.hero.flyRange.indexOf(core.status.floorId); var stair=core.status.event.data=8) { nextId--; while (nextId>=0 && nextId!=now && core.floors[core.floorIds[nextId]].cannotViewMap) nextId--; if (nextId>=0) core.ui.drawMaps(nextId); } else { core.clearMap('data', 0, 0, 416, 416); core.setOpacity('data', 1); core.ui.closePanel(); } } ////// 查看地图界面时,按下某个键的操作 ////// actions.prototype.keyDownViewMaps = function (keycode) { if (keycode==37 || keycode==38 || keycode==33) { this.clickViewMaps(6,2); } else if (keycode==39 || keycode==40 || keycode==34) { this.clickViewMaps(6,10); } return; } ////// 查看地图界面时,放开某个键的操作 ////// actions.prototype.keyUpViewMaps = function (keycode) { if (keycode==27 || keycode==13 || keycode==32 || keycode==67) { core.clearMap('data', 0, 0, 416, 416); core.setOpacity('data', 1); core.ui.closePanel(); } if (keycode==88) { core.openBook(false); } return; } ////// 商店界面时的点击操作 ////// actions.prototype.clickShop = function(x,y) { var shop = core.status.event.data.shop; var choices = shop.choices; if (x >= 5 && x <= 7) { var topIndex = 6 - parseInt(choices.length / 2); if (y>=topIndex && y eval(use)) { core.drawTip("你的"+use_text+"不足"); return false; } core.status.event.data.actions.push(y-topIndex); eval(use+'-='+need); core.setStatus('money', money); core.setStatus('experience', experience); // 更新属性 choice.effect.split(";").forEach(function (t) { core.doEffect(t); }); core.updateStatusBar(); shop.times++; core.events.openShop(core.status.event.data.id); } // 离开 else if (y==topIndex+choices.length) { if (core.status.event.data.actions.length>0) { core.status.route.push("shop:"+core.status.event.data.id+":"+core.status.event.data.actions.join("")); } core.status.event.data.actions = []; core.status.boxAnimateObjs = []; if (core.status.event.data.fromList) core.ui.drawQuickShop(); else core.ui.closePanel(); } else return false; } return true; } ////// 商店界面时,按下某个键的操作 ////// actions.prototype.keyDownShop = function (keycode) { if (keycode==38) { core.status.event.selection--; core.ui.drawChoices(core.status.event.ui.text, core.status.event.ui.choices); } if (keycode==40) { core.status.event.selection++; core.ui.drawChoices(core.status.event.ui.text, core.status.event.ui.choices); } } ////// 商店界面时,放开某个键的操作 ////// actions.prototype.keyUpShop = function (keycode) { if (keycode==27 || keycode==88) { if (core.status.event.data.actions.length>0) { core.status.route.push("shop:"+core.status.event.data.id+":"+core.status.event.data.actions.join("")); } core.status.event.data.actions = []; core.status.boxAnimateObjs = []; if (core.status.event.data.fromList) core.ui.drawQuickShop(); else core.ui.closePanel(); return; } var shop = core.status.event.data.shop; var choices = shop.choices; if (keycode==13 || keycode==32 || keycode==67) { var topIndex = 6 - parseInt(choices.length / 2); this.clickShop(6, topIndex+core.status.event.selection); } return; } ////// 快捷商店界面时的点击操作 ////// actions.prototype.clickQuickShop = function(x, y) { var shopList = core.status.shops, keys = Object.keys(shopList); if (x >= 5 && x <= 7) { var topIndex = 6 - parseInt(keys.length / 2); if (y>=topIndex && y=10 && x<=12 && y==12) { core.ui.closePanel(); return; } if (x>=10 && x<=12 && y<=1) { if (!core.isset(core.status.event.data)) return; if (!core.flags.enableDeleteItem) { core.drawTip("不支持删除道具!"); return; } core.removeItem(core.status.event.data); core.status.event.data = null; core.ui.drawToolbox(); return; } var index=0; if (y==4||y==5||y==9||y==10) index=parseInt(x/2); else index=6+parseInt(x/2); if (y>=9) index+=100; this.clickToolboxIndex(index); } ////// 选择工具栏界面中某个Index后的操作 ////// actions.prototype.clickToolboxIndex = function(index) { var items = null; var ii=index; if (ii<100) items = Object.keys(core.status.hero.items.tools).sort(); else { ii-=100; items = Object.keys(core.status.hero.items.constants).sort(); } if (items==null) return; if (ii>=items.length) return; var itemId=items[ii]; if (itemId==core.status.event.data) { core.events.useItem(itemId); } else { core.ui.drawToolbox(index); } } ////// 工具栏界面时,按下某个键的操作 ////// actions.prototype.keyDownToolbox = function (keycode) { if (!core.isset(core.status.event.data)) return; var tools = Object.keys(core.status.hero.items.tools).sort(); var constants = Object.keys(core.status.hero.items.constants).sort(); var index=core.status.event.selection; if (keycode==37) { // left if ((index>0 && index<100) || index>100) { this.clickToolboxIndex(index-1); return; } if (index==100 && tools.length>0) { this.clickToolboxIndex(tools.length-1); return; } } if (keycode==38) { // up if ((index>5 && index<100) || index>105) { this.clickToolboxIndex(index-6); return; } if (index>=100 && index<=105) { if (tools.length>6) { this.clickToolboxIndex(Math.min(tools.length-1, index-100+6)); } else if (tools.length>0) { this.clickToolboxIndex(Math.min(tools.length-1, index-100)); } return; } } if (keycode==39) { // right if ((index=100 && index0) { this.clickToolboxIndex(100); return; } } if (keycode==40) { // down if (index<=5) { if (tools.length>6) { this.clickToolboxIndex(Math.min(tools.length-1, index+6)); } else if (constants.length>0) { this.clickToolboxIndex(100+Math.min(constants.length-1, index)); } return; } if (index>5 && index<100 && constants.length>0) { this.clickToolboxIndex(100+Math.min(constants.length-1, index-6)); return; } if (index>=100 && index<=105 && constants.length>6) { this.clickToolboxIndex(Math.min(100+constants.length-1, index+6)); return; } } } ////// 工具栏界面时,放开某个键的操作 ////// actions.prototype.keyUpToolbox = function (keycode) { if (keycode==84 || keycode==27 || keycode==88) { core.ui.closePanel(); return; } if (!core.isset(core.status.event.data)) return; if (keycode==13 || keycode==32 || keycode==67) { this.clickToolboxIndex(core.status.event.selection); return; } if (keycode==46) { // delete if (!core.isset(core.status.event.data)) return; if (!core.flags.enableDeleteItem) { core.drawTip("不支持删除道具!"); return; } core.removeItem(core.status.event.data); core.status.event.data = null; core.ui.drawToolbox(); return; } } ////// 存读档界面时的点击操作 ////// actions.prototype.clickSL = function(x,y) { var index=core.status.event.data; var page = parseInt(index/10), offset=index%10; // 上一页 if ((x == 3 || x == 4) && y == 12) { core.ui.drawSLPanel(10*(page-1)+offset); return; } // 下一页 if ((x == 8 || x == 9) && y == 12) { core.ui.drawSLPanel(10*(page+1)+offset); return; } // 返回 if (x>=10 && x<=12 && y==12) { core.ui.closePanel(); if (!core.isPlaying()) { core.showStartAnimate(); } return; } // 删除 if (x>=0 && x<=2 && y==12) { core.status.event.selection=!core.status.event.selection; core.ui.drawSLPanel(index); return; } var id=null; if (y>=1 && y<=4) { if (x>=1 && x<=3) id = "autoSave"; if (x>=5 && x<=7) id = 5*page+1; if (x>=9 && x<=11) id = 5*page+2; } if (y>=7 && y<=10) { if (x>=1 && x<=3) id = 5*page+3; if (x>=5 && x<=7) id = 5*page+4; if (x>=9 && x<=11) id = 5*page+5; } if (id!=null) { if (core.status.event.selection) { if (id == 'autoSave') { core.drawTip("无法删除自动存档!"); } else { core.removeLocalStorage("save"+id); core.ui.drawSLPanel(index); } } else { core.doSL(id, core.status.event.id); } } } ////// 存读档界面时,按下某个键的操作 ////// actions.prototype.keyDownSL = function(keycode) { var index=core.status.event.data; var page = parseInt(index/10), offset=index%10; if (keycode==37) { // left if (offset==0) { core.ui.drawSLPanel(10*(page-1) + 5); } else { core.ui.drawSLPanel(index - 1); } return; } if (keycode==38) { // up if (offset<3) { core.ui.drawSLPanel(10*(page-1) + offset + 3); } else { core.ui.drawSLPanel(index - 3); } return; } if (keycode==39) { // right if (offset==5) { core.ui.drawSLPanel(10*(page+1)+1); } else { core.ui.drawSLPanel(index + 1); } return; } if (keycode==40) { // down if (offset>=3) { core.ui.drawSLPanel(10*(page+1) + offset - 3); } else { core.ui.drawSLPanel(index + 3); } return; } if (keycode==33) { // PAGEUP core.ui.drawSLPanel(10*(page-1) + offset); return; } if (keycode==34) { // PAGEDOWN core.ui.drawSLPanel(10*(page+1) + offset); return; } } ////// 存读档界面时,放开某个键的操作 ////// actions.prototype.keyUpSL = function (keycode) { var index=core.status.event.data; var page = parseInt(index/10), offset=index%10; if (keycode==27 || keycode==88 || (core.status.event.id == 'save' && keycode==83) || (core.status.event.id == 'load' && keycode==68)) { core.ui.closePanel(); if (!core.isPlaying()) { core.showStartAnimate(); } return; } if (keycode==13 || keycode==32 || keycode==67) { if (offset==0) { core.doSL("autoSave", core.status.event.id); } else { core.doSL(5*page+offset, core.status.event.id); } return; } if (keycode==46) { if (offset==0) { core.drawTip("无法删除自动存档!"); } else { core.removeLocalStorage("save"+(5*page+offset)); core.ui.drawSLPanel(index); } } } ////// 系统设置界面时的点击操作 ////// actions.prototype.clickSwitchs = function (x,y) { if (x<5 || x>7) return; var choices = core.status.event.ui.choices; var topIndex = 6 - parseInt((choices.length - 1) / 2); if (y>=topIndex && y7) return; var choices = core.status.event.ui.choices; var topIndex = 6 - parseInt((choices.length - 1) / 2); if (y>=topIndex && y0) { text+="\n当前MAX为"+ending.max+",最早由 "+(ending.username||"匿名")+" 于"+core.formatDate(new Date(1000*ending.timestamp))+"打出。"; } }) }) core.drawText(text); } } else { core.drawText("出错啦!\n无法拉取统计信息。\n错误原因:HTTP "+xhr.status); } }; xhr.ontimeout = function() { core.drawText("出错啦!\n无法拉取统计信息。\n错误原因:Timeout"); } xhr.onerror = function() { core.drawText("出错啦!\n无法拉取统计信息。\n错误原因:XHR Error"); } xhr.send(formData); break; case 6: core.ui.drawHelp(); break; case 7: core.ui.drawAbout(); break; case 8: core.ui.closePanel(); break; } } return; } ////// 系统菜单栏界面时,按下某个键的操作 ////// actions.prototype.keyDownSettings = function (keycode) { if (keycode==38) { core.status.event.selection--; core.ui.drawChoices(core.status.event.ui.text, core.status.event.ui.choices); } if (keycode==40) { core.status.event.selection++; core.ui.drawChoices(core.status.event.ui.text, core.status.event.ui.choices); } } ////// 系统菜单栏界面时,放开某个键的操作 ////// actions.prototype.keyUpSettings = function (keycode) { if (keycode==27 || keycode==88) { core.ui.closePanel(); return; } var choices = core.status.event.ui.choices; if (keycode==13 || keycode==32 || keycode==67) { var topIndex = 6 - parseInt((choices.length - 1) / 2); this.clickSettings(6, topIndex+core.status.event.selection); } } ////// 同步存档界面时的点击操作 ////// actions.prototype.clickSyncSave = function (x,y) { if (x<5 || x>7) return; var choices = core.status.event.ui.choices; var topIndex = 6 - parseInt((choices.length - 1) / 2); if (y>=topIndex && y=1;i--) { if (core.getLocalStorage("save"+i, null)==null) index=i; else break; } core.setLocalStorage("save"+index, data); core.drawText("同步成功!\n单存档已覆盖至存档"+index); } }, function () { }); break; case 4: core.download(core.firstData.name+"_"+core.formatDate2(new Date())+".h5route", JSON.stringify({ 'name': core.firstData.name, 'hard': core.status.hard, 'seed': core.getFlag('seed'), 'route': core.encodeRoute(core.status.route) })); break; case 5: core.status.event.selection=0; core.ui.drawStorageRemove(); break; case 6: core.status.event.selection=3; core.ui.drawSettings(); break; } } return; } ////// 同步存档界面时,按下某个键的操作 ////// actions.prototype.keyDownSyncSave = function (keycode) { if (keycode==38) { core.status.event.selection--; core.ui.drawChoices(core.status.event.ui.text, core.status.event.ui.choices); } if (keycode==40) { core.status.event.selection++; core.ui.drawChoices(core.status.event.ui.text, core.status.event.ui.choices); } } ////// 同步存档界面时,放开某个键的操作 ////// actions.prototype.keyUpSyncSave = function (keycode) { if (keycode==27 || keycode==88) { core.status.event.selection=2; core.ui.drawSettings(); return; } var choices = core.status.event.ui.choices; if (keycode==13 || keycode==32 || keycode==67) { var topIndex = 6 - parseInt((choices.length - 1) / 2); this.clickSyncSave(6, topIndex+core.status.event.selection); } } ////// 同步存档选择界面时的点击操作 ////// actions.prototype.clickSyncSelect = function (x, y) { if (x<5 || x>7) return; var choices = core.status.event.ui.choices; var topIndex = 6 - parseInt((choices.length - 1) / 2); if (y>=topIndex && y7) return; var choices = core.status.event.ui.choices; var topIndex = 6 - parseInt((choices.length - 1) / 2); var saves=null; if (y>=topIndex && y=1;i--) { saves=core.getLocalStorage("save"+i, null); if (core.isset(saves)) { break; } } break; case 2: break; } } if (core.isset(saves)) { var content = { "name": core.firstData.name, "version": core.firstData.version, "data": saves } core.download(core.firstData.name+"_"+core.formatDate2(new Date())+".h5save", JSON.stringify(content)); } core.status.event.selection=2; core.ui.drawSyncSave(); } ////// 存档下载界面时,按下某个键的操作 ////// actions.prototype.keyDownLocalSaveSelect = function (keycode) { if (keycode==38) { core.status.event.selection--; core.ui.drawChoices(core.status.event.ui.text, core.status.event.ui.choices); } if (keycode==40) { core.status.event.selection++; core.ui.drawChoices(core.status.event.ui.text, core.status.event.ui.choices); } } ////// 存档下载界面时,放开某个键的操作 ////// actions.prototype.keyUpLocalSaveSelect = function (keycode) { if (keycode==27 || keycode==88) { core.status.event.selection=0; core.ui.drawSettings(); return; } var choices = core.status.event.ui.choices; if (keycode==13 || keycode==32 || keycode==67) { var topIndex = 6 - parseInt((choices.length - 1) / 2); this.clickLocalSaveSelect(6, topIndex+core.status.event.selection); } } ////// 存档删除界面时的点击操作 ////// actions.prototype.clickStorageRemove = function (x, y) { if (x<5 || x>7) return; var choices = core.status.event.ui.choices; var topIndex = 6 - parseInt((choices.length - 1) / 2); if (y>=topIndex && y7) return; var choices = core.status.event.ui.choices; var topIndex = 6 - parseInt((choices.length - 1) / 2); if (y>=topIndex && y=1 && x<=11) { core.ui.closePanel(); core.keyUp(112+x-1); // F1-F12: 112-122 } if (y==4 && x>=1 && x<=10) { core.ui.closePanel(); core.keyUp(x==10?48:48+x); // 1-9: 49-57; 0: 48 } // 字母 var lines = [ ["Q","W","E","R","T","Y","U","I","O","P"], ["A","S","D","F","G","H","J","K","L"], ["Z","X","C","V","B","N","M"], ]; if (y==5 && x>=1 && x<=10) { core.ui.closePanel(); core.keyUp(lines[0][x-1].charCodeAt(0)); } if (y==6 && x>=1 && x<=9) { core.ui.closePanel(); core.keyUp(lines[1][x-1].charCodeAt(0)); } if (y==7 && x>=1 && x<=7) { core.ui.closePanel(); core.keyUp(lines[2][x-1].charCodeAt(0)); } if (y==8 && x>=1 && x<=11) { core.ui.closePanel(); if (x==1) core.keyUp(189); // - if (x==2) core.keyUp(187); // = if (x==3) core.keyUp(219); // [ if (x==4) core.keyUp(221); // ] if (x==5) core.keyUp(220); // \ if (x==6) core.keyUp(186); // ; if (x==7) core.keyUp(222); // ' if (x==8) core.keyUp(188); // , if (x==9) core.keyUp(190); // . if (x==10) core.keyUp(191); // / if (x==11) core.keyUp(192); // ` } if (y==9 && x>=1 && x<=10) { core.ui.closePanel(); if (x==1) core.keyUp(27); // ESC if (x==2) core.keyUp(9); // TAB if (x==3) core.keyUp(20); // CAPS if (x==4) core.keyUp(16); // SHIFT if (x==5) core.keyUp(17); // CTRL if (x==6) core.keyUp(18); // ALT if (x==7) core.keyUp(32); // SPACE if (x==8) core.keyUp(8); // BACKSPACE if (x==9) core.keyUp(13); // ENTER if (x==10) core.keyUp(46); // DEL } if (y==10 && x>=9 && x<=11) core.ui.closePanel(); } ////// 光标界面时的点击操作 ////// actions.prototype.clickCursor = function (x,y) { if (x==core.status.automaticRoute.cursorX && y==core.status.automaticRoute.cursorY) { core.ui.closePanel(); core.onclick(x,y,[]); return; } core.status.automaticRoute.cursorX=x; core.status.automaticRoute.cursorY=y; core.ui.drawCursor(); } ////// 光标界面时,按下某个键的操作 ////// actions.prototype.keyDownCursor = function (keycode) { if (keycode==37) { // left core.status.automaticRoute.cursorX--; core.ui.drawCursor(); return; } if (keycode==38) { // up core.status.automaticRoute.cursorY--; core.ui.drawCursor(); return; } if (keycode==39) { // right core.status.automaticRoute.cursorX++; core.ui.drawCursor(); return; } if (keycode==40) { // down core.status.automaticRoute.cursorY++; core.ui.drawCursor(); return; } } ////// 光标界面时,放开某个键的操作 ////// actions.prototype.keyUpCursor = function (keycode) { if (keycode==27 || keycode==88) { core.ui.closePanel(); return; } if (keycode==13 || keycode==32 || keycode==67 || keycode==69) { core.ui.closePanel(); core.onclick(core.status.automaticRoute.cursorX, core.status.automaticRoute.cursorY, []); return; } } ////// “关于”界面时的点击操作 ////// actions.prototype.clickAbout = function () { if (core.isPlaying()) core.ui.closePanel(); else core.restart(); }