From b6c37a5c9f0db47957666f3017abd845bc70f002 Mon Sep 17 00:00:00 2001 From: MrZ626 <1046101471@qq.com> Date: Sat, 27 Nov 2021 23:16:21 +0800 Subject: [PATCH] =?UTF-8?q?=E6=A1=86=E6=9E=B6keyDown=E4=BA=8B=E4=BB=B6?= =?UTF-8?q?=E6=9C=BA=E5=88=B6=E5=BE=AE=E8=B0=83=EF=BC=8C=E9=87=8D=E6=9E=84?= =?UTF-8?q?=E6=A1=86=E6=9E=B6=E4=B8=BB=E5=BE=AA=E7=8E=AF=E5=92=8C=E6=8E=A7?= =?UTF-8?q?=E4=BB=B6=E7=9B=B8=E5=85=B3=E4=BB=A3=E7=A0=81=20=E5=8F=AF?= =?UTF-8?q?=E4=BB=A5=E7=94=A8=E9=94=AE=E7=9B=98=E5=92=8C=E6=89=8B=E6=9F=84?= =?UTF-8?q?=E6=8E=A7=E5=88=B6=E5=85=89=E6=A0=87=EF=BC=88=E6=89=8B=E6=9F=84?= =?UTF-8?q?=E4=B8=8D=E5=AE=8C=E5=96=84=EF=BC=89=20=E6=95=B4=E7=90=86?= =?UTF-8?q?=E4=BB=A3=E7=A0=81=E5=92=8C=E9=83=A8=E5=88=86=E8=AF=AD=E8=A8=80?= =?UTF-8?q?=E6=96=87=E4=BB=B6=E7=BB=86=E8=8A=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Zframework/init.lua | 184 +++++++++++++++++++++----------- Zframework/widget.lua | 86 +-------------- parts/language/lang_en.lua | 8 +- parts/language/lang_fr.lua | 6 +- parts/language/lang_pt.lua | 8 +- parts/scenes/about.lua | 6 +- parts/scenes/app_arithmetic.lua | 2 +- parts/scenes/app_console.lua | 8 +- parts/scenes/app_dropper.lua | 2 +- parts/scenes/app_polyforge.lua | 2 +- parts/scenes/customGame.lua | 67 ++++++------ parts/scenes/dict.lua | 4 +- parts/scenes/main.lua | 114 ++++++-------------- parts/scenes/net_newRoom.lua | 12 +-- parts/scenes/net_rooms.lua | 40 +++---- parts/scenes/pause.lua | 4 +- parts/scenes/replays.lua | 4 +- parts/scenes/setting_key.lua | 8 +- parts/scenes/setting_sound.lua | 6 +- parts/scenes/staff.lua | 6 +- parts/scenes/stat.lua | 8 +- 21 files changed, 246 insertions(+), 339 deletions(-) diff --git a/Zframework/init.lua b/Zframework/init.lua index b1287047..d30185b9 100644 --- a/Zframework/init.lua +++ b/Zframework/init.lua @@ -60,6 +60,7 @@ BGM= require'Zframework.bgm' VOC= require'Zframework.voice' local ms,kb=love.mouse,love.keyboard +local KBisDown=kb.isDown local gc=love.graphics local gc_push,gc_pop,gc_clear,gc_discard=gc.push,gc.pop,gc.clear,gc.discard @@ -69,9 +70,11 @@ local gc_draw,gc_line,gc_circle,gc_print=gc.draw,gc.line,gc.circle,gc.print local WIDGET,SCR,SCN=WIDGET,SCR,SCN local xOy=SCR.xOy -local ITP=xOy.inverseTransformPoint -local mx,my,mouseShow=-20,-20,false +local ITP=xOy.inverseTransformPoint +local max,min=math.max,math.min + +local mx,my,mouseShow,cursorSpd=-20,-20,false,0 local jsState={}--map, joystickID->axisStates: {axisName->axisVal} local errData={}--list, each error create {mes={errMes strings},scene=sceneNameStr} @@ -126,36 +129,61 @@ local function updatePowerInfo() end ------------------------------------------------------------- local lastX,lastY=0,0--Last click pos +local function _updateMousePos(x,y,dx,dy) + if SCN.swapping then return end + dx,dy=dx/SCR.k,dy/SCR.k + if SCN.mouseMove then SCN.mouseMove(x,y,dx,dy)end + if ms.isDown(1)then + WIDGET.drag(x,y,dx,dy) + else + WIDGET.cursorMove(x,y) + end +end +local function _triggerMouseDown(x,y,k) + if devMode==1 then + print(("(%d,%d)<-%d,%d ~~(%d,%d)<-%d,%d"):format( + x,y, + x-lastX,y-lastY, + math.floor(x/10)*10,math.floor(y/10)*10, + math.floor((x-lastX)/10)*10,math.floor((y-lastY)/10)*10 + )) + end + if SCN.swapping then return end + if SCN.mouseDown then SCN.mouseDown(x,y,k)end + WIDGET.press(x,y,k) + lastX,lastY=x,y + if SETTING.clickFX then SYSFX.newTap(3,x,y)end +end +local function _mouse_update(dt) + if not KBisDown('lctrl','rctrl')and KBisDown('up','down','left','right')then + local dx,dy=0,0 + if KBisDown('up')then dy=dy-cursorSpd end + if KBisDown('down')then dy=dy+cursorSpd end + if KBisDown('left')then dx=dx-cursorSpd end + if KBisDown('right')then dx=dx+cursorSpd end + mx=max(min(mx+dx,1280),0) + my=max(min(my+dy,720),0) + if my==0 or my==720 then + WIDGET.sel=false + WIDGET.drag(0,0,0,-dy) + end + _updateMousePos(mx,my,dx,dy) + cursorSpd=min(cursorSpd+dt*26,12.6) + else + cursorSpd=6 + end +end function love.mousepressed(x,y,k,touch) if touch then return end mouseShow=true mx,my=ITP(xOy,x,y) - if devMode==1 then - print(("(%d,%d)<-%d,%d ~~(%d,%d)<-%d,%d"):format( - mx,my, - mx-lastX,my-lastY, - math.floor(mx/10)*10,math.floor(my/10)*10, - math.floor((mx-lastX)/10)*10,math.floor((my-lastY)/10)*10 - )) - end - if SCN.swapping then return end - if SCN.mouseDown then SCN.mouseDown(mx,my,k)end - WIDGET.press(mx,my,k) - lastX,lastY=mx,my - if SETTING.clickFX then SYSFX.newTap(3,mx,my)end + _triggerMouseDown(mx,my,k) end function love.mousemoved(x,y,dx,dy,touch) if touch then return end mouseShow=true mx,my=ITP(xOy,x,y) - if SCN.swapping then return end - dx,dy=dx/SCR.k,dy/SCR.k - if SCN.mouseMove then SCN.mouseMove(mx,my,dx,dy)end - if ms.isDown(1)then - WIDGET.drag(mx,my,dx/SCR.k,dy/SCR.k) - else - WIDGET.cursorMove(mx,my) - end + _updateMousePos(mx,my,dx,dy) end function love.mousereleased(x,y,k,touch) if touch or SCN.swapping then return end @@ -264,14 +292,26 @@ function love.keypressed(key,_,isRep) applyFullscreen() saveSettings() elseif not SCN.swapping then - if SCN.keyDown then - if EDITING==""then - SCN.keyDown(key,isRep) + if EDITING==""and(not SCN.keyDown or SCN.keyDown(key,isRep))then + local W=WIDGET.sel + if key=='escape'and not isRep then + SCN.back() + elseif key=='up'or key=='down'or key=='left'or key=='right'then + mouseShow=true + if KBisDown('lctrl','rctrl')then + if W and W.arrowKey then W:arrowKey(key)end + end + elseif key=='space'or key=='return'then + mouseShow=true + if not isRep then + if SETTING.clickFX then SYSFX.newTap(3,mx,my)end + _triggerMouseDown(mx,my,1) + end + else + if W and W.keypress then + W:keypress(key) + end end - elseif key=='escape'and not isRep then - SCN.back() - else - WIDGET.keyPressed(key,isRep) end end end @@ -367,13 +407,36 @@ function love.gamepadaxis(JS,axis,val) end end end -function love.gamepadpressed(_,i) +function love.gamepadpressed(_,key) mouseShow=false - if SCN.swapping then return end - if SCN.gamepadDown then SCN.gamepadDown(i) - elseif SCN.keyDown then SCN.keyDown(dPadToKey[i]or i) - elseif i=="back"then SCN.back() - else WIDGET.gamepadPressed(dPadToKey[i]or i) + if not SCN.swapping then + local cursorCtrl + if SCN.gamepadDown then + cursorCtrl=SCN.gamepadDown(key) + elseif SCN.keyDown then + cursorCtrl=SCN.keyDown(dPadToKey[key]or key) + else + cursorCtrl=true + end + if cursorCtrl then + key=dPadToKey[key]or key + mouseShow=true + local W=WIDGET.sel + if key=='back'then + SCN.back() + elseif key=='up'or key=='down'or key=='left'or key=='right'then + mouseShow=true + if W and W.arrowKey then W:arrowKey(key)end + elseif key=='return'then + mouseShow=true + if SETTING.clickFX then SYSFX.newTap(3,mx,my)end + _triggerMouseDown(mx,my,1) + else + if W and W.keypress then + W:keypress(key) + end + end + end end end function love.gamepadreleased(_,i) @@ -513,7 +576,7 @@ local devColor={ } local WS=WS local WSnames={'app','user','play','stream','chat','manage'} -local wsBottomImage do +local wsImg={}do local L={78,18, {'clear',1,1,1,0}, {'setCL',1,1,1,.3}, @@ -523,23 +586,23 @@ local wsBottomImage do table.insert(L,{'setCL',1,1,1,i*.005}) table.insert(L,{'fRect',i,0,1,18}) end - wsBottomImage=GC.DO(L) + wsImg.bottom=GC.DO(L) + wsImg.dead=GC.DO{20,20, + {'rawFT',20}, + {'setCL',1,.3,.3}, + {'mText',"X",11,-1}, + } + wsImg.connecting=GC.DO{20,20, + {'rawFT',20}, + {'setLW',3}, + {'mText',"C",11,-1}, + } + wsImg.running=GC.DO{20,20, + {'rawFT',20}, + {'setCL',.5,1,0}, + {'mText',"R",11,-1}, + } end -local ws_deadImg=GC.DO{20,20, - {'rawFT',20}, - {'setCL',1,.3,.3}, - {'mText',"X",11,-1}, -} -local ws_connectingImg=GC.DO{20,20, - {'rawFT',20}, - {'setLW',3}, - {'mText',"C",11,-1}, -} -local ws_runningImg=GC.DO{20,20, - {'rawFT',20}, - {'setCL',.5,1,0}, - {'mText',"R",11,-1}, -} local function drawCursor(_,x,y) gc_setColor(1,1,1) @@ -559,7 +622,7 @@ function love.run() local TASK_update=TASK.update local SYSFX_update,SYSFX_draw=SYSFX.update,SYSFX.draw local WIDGET_update,WIDGET_draw=WIDGET.update,WIDGET.draw - + local VOC_update,BG_update=VOC.update,BG.update local STEP,WAIT=love.timer.step,love.timer.sleep local FPS,MINI=love.timer.getFPS,love.window.isMinimized local PUMP,POLL=love.event.pump,love.event.poll @@ -598,8 +661,9 @@ function love.run() --UPDATE STEP() - VOC.update() - BG.update(dt) + if mouseShow then _mouse_update(dt)end + VOC_update() + BG_update(dt) TEXT_update(dt) MES_update(dt) WS_update(dt) @@ -689,14 +753,14 @@ function love.run() for i=1,6 do local status=WS.status(WSnames[i]) gc_setColor(1,1,1) - gc.draw(wsBottomImage,-79,20*i-139) + gc.draw(wsImg.bottom,-79,20*i-139) if status=='dead'then - gc_draw(ws_deadImg,-20,20*i-140) + gc_draw(wsImg.dead,-20,20*i-140) elseif status=='connecting'then gc_setColor(1,1,1,.5+.3*math.sin(time*6.26)) - gc_draw(ws_connectingImg,-20,20*i-140) + gc_draw(wsImg.connecting,-20,20*i-140) elseif status=='running'then - gc_draw(ws_runningImg,-20,20*i-140) + gc_draw(wsImg.running,-20,20*i-140) end local t1,t2,t3=WS.getTimers(WSnames[i]) gc_setColor(.9,.9,.9,t1)gc.rectangle('fill',-60,20*i-122,-16,-16) diff --git a/Zframework/widget.lua b/Zframework/widget.lua index 330e82cd..aa1ff78b 100644 --- a/Zframework/widget.lua +++ b/Zframework/widget.lua @@ -13,7 +13,7 @@ local kb=love.keyboard local timer=love.timer.getTime local next=next -local int,ceil,abs=math.floor,math.ceil,math.abs +local int,ceil=math.floor,math.ceil local max,min=math.max,math.min local sub,ins,rem=string.sub,table.insert,table.remove local mDraw,mDraw_X,mDraw_Y=GC.draw,GC.simpX,GC.simpY @@ -1380,59 +1380,6 @@ function WIDGET.release(x,y) W:release(x,y+WIDGET.scrollPos) end end -function WIDGET.keyPressed(k,isRep) - local W=WIDGET.sel - if k=='space'or k=='return'then - if not isRep then - WIDGET.press() - end - elseif k=='up'or k=='down'or k=='left'or k=='right'then - if kb.isDown('lshift','lalt','lctrl','rshift','ralt','rctrl')then - --Control some widgets with arrowkeys when hold shift/ctrl/alt - if W and W.arrowKey then W:arrowKey(k)end - else - if not W then - for _,w in next,WIDGET.active do - if not w.hide and w.isAbove then - WIDGET.focus(w) - return - end - end - elseif W.getCenter then - local WX,WY=W:getCenter() - local dir=(k=='right'or k=='down')and 1 or -1 - local tar - local minDist=1e99 - local swap_xy=k=='up'or k=='down' - if swap_xy then WX,WY=WY,WX end--note that we do not swap them back later - for _,W1 in ipairs(WIDGET.active)do - if W~=W1 and W1.resCtr and not W1.hide then - local L=W1.resCtr - for j=1,#L,2 do - local x,y=L[j],L[j+1] - if swap_xy then x,y=y,x end--note that we do not swap them back later - local dist=(x-WX)*dir - if dist>10 then - dist=dist+abs(y-WY)*6.26 - if dist0 and p-1)or p.18 then - W.lastTime=timer() - W.change() - end - end - end - elseif i=='dpup'or i=='dpdown'or i=='dpleft'or i=='dpright'then - WIDGET.keyPressed(keyMirror[i]) - end -end function WIDGET.update(dt) for _,W in next,WIDGET.active do diff --git a/parts/language/lang_en.lua b/parts/language/lang_en.lua index e3ed613c..ca3a6ec7 100644 --- a/parts/language/lang_en.lua +++ b/parts/language/lang_en.lua @@ -541,13 +541,13 @@ return{ any="Erase", smart="Smart", - push="Add Line(K)", - del="Del Line(L)", + push="Add Line (K)", + del="Del Line (L)", demo="Don't Show ×", - newPg="New Page(N)", - delPg="Del Page(M)", + newPg="New Page (N)", + delPg="Del Page (M)", prevPg="Prev Page", nextPg="Next Page", }, diff --git a/parts/language/lang_fr.lua b/parts/language/lang_fr.lua index 2e524ae3..82159250 100644 --- a/parts/language/lang_fr.lua +++ b/parts/language/lang_fr.lua @@ -472,7 +472,7 @@ return{ mod="Mods (F1)", field="Modifier la matrice (F)", sequence="Modifier la séquence (S)", - mission="Modifier la mission(M)", + mission="Modifier la mission (M)", -- eventSet="Rule Set", @@ -512,8 +512,8 @@ return{ demo="Masquer les ×", - newPg="Nouvelle Page(N)", - delPg="Supp. Page(M)", + newPg="Nouvelle Page (N)", + delPg="Supp. Page (M)", prevPg="Page Préc.", nextPg="Page Suiv.", }, diff --git a/parts/language/lang_pt.lua b/parts/language/lang_pt.lua index 52cb157b..b89f13e8 100644 --- a/parts/language/lang_pt.lua +++ b/parts/language/lang_pt.lua @@ -529,13 +529,13 @@ return{ any="Apagar", -- smart="Smart", - push="Add Linha(K)", - del="Del Linha(L)", + push="Add Linha (K)", + del="Del Linha (L)", demo="Não mostrar ×", - newPg="Nova Página(N)", - delPg="Del Página(M)", + newPg="Nova Página (N)", + delPg="Del Página (M)", prevPg="Página Ant.", nextPg="Prox. Página", }, diff --git a/parts/scenes/about.lua b/parts/scenes/about.lua index 5ca2d966..6003a374 100644 --- a/parts/scenes/about.lua +++ b/parts/scenes/about.lua @@ -16,10 +16,10 @@ end scene.touchDown=scene.mouseDown function scene.keyDown(key) - if key=='escape'then - SCN.back() - elseif key=='space'then + if key=='space'then loadGame('stack_e',true) + else + return true end end diff --git a/parts/scenes/app_arithmetic.lua b/parts/scenes/app_arithmetic.lua index 279cf73e..0d91dc1b 100644 --- a/parts/scenes/app_arithmetic.lua +++ b/parts/scenes/app_arithmetic.lua @@ -229,7 +229,7 @@ scene.widgetList={ WIDGET.newKey{name='7',x=540,y=320,w=90,font=60,fText="7",code=pressKey'7'}, WIDGET.newKey{name='8',x=640,y=320,w=90,font=60,fText="8",code=pressKey'8'}, WIDGET.newKey{name='9',x=740,y=320,w=90,font=60,fText="9",code=pressKey'9'}, - WIDGET.newButton{name='back',x=1200,y=660,w=110,h=60,font=60,fText=CHAR.icon.back,code=pressKey'escape'}, + WIDGET.newButton{name='back',x=1200,y=660,w=110,h=60,font=60,fText=CHAR.icon.back,code=backScene}, } return scene diff --git a/parts/scenes/app_console.lua b/parts/scenes/app_console.lua index edb7043a..3f6954a9 100644 --- a/parts/scenes/app_console.lua +++ b/parts/scenes/app_console.lua @@ -4,7 +4,7 @@ local ins,rem=table.insert,table.remove local C=COLOR local inputBox=WIDGET.newInputBox{name='input',x=40,y=650,w=1200,h=50,fType='mono'} -local outputBox=WIDGET.newTextBox{name='output',x=40,y=30,w=1200,h=610,font=25,fType='mono',lineH=25,fix=true} +local outputBox=WIDGET.newTextBox{name='output',x=40,y=30,w=1200,h=610,font=25,fType='mono',lineH=23,fix=true} local function log(str)outputBox:push(str)end log{C.lP,"Techmino Console"} @@ -1088,8 +1088,8 @@ function scene.keyDown(key) end elseif key=='scrollup'then outputBox:scroll(-5) elseif key=='scrolldown'then outputBox:scroll(5) - elseif key=='pageup'then outputBox:scroll(-20) - elseif key=='pagedown'then outputBox:scroll(20) + elseif key=='pageup'then outputBox:scroll(-25) + elseif key=='pagedown'then outputBox:scroll(25) elseif key=='home'then outputBox:scroll(-1e99) elseif key=='end'then outputBox:scroll(1e99) elseif combKey[key]and kb.isDown('lctrl','rctrl')then combKey[key]() @@ -1103,7 +1103,7 @@ function scene.keyDown(key) if not WIDGET.isFocus(inputBox)then WIDGET.focus(inputBox) end - WIDGET.keyPressed(key) + return true end end diff --git a/parts/scenes/app_dropper.lua b/parts/scenes/app_dropper.lua index 149480cf..cae2d2f6 100644 --- a/parts/scenes/app_dropper.lua +++ b/parts/scenes/app_dropper.lua @@ -234,7 +234,7 @@ function scene.draw() end scene.widgetList={ - WIDGET.newButton{name='back',x=1140,y=60,w=170,h=80,font=60,fText=CHAR.icon.back,code=pressKey'escape'}, + WIDGET.newButton{name='back',x=1140,y=60,w=170,h=80,font=60,fText=CHAR.icon.back,code=backScene}, } return scene diff --git a/parts/scenes/app_polyforge.lua b/parts/scenes/app_polyforge.lua index 723fdc0e..a4d1f358 100644 --- a/parts/scenes/app_polyforge.lua +++ b/parts/scenes/app_polyforge.lua @@ -163,7 +163,7 @@ function scene.draw() end scene.widgetList={ - WIDGET.newKey{name='back',x=1140,y=60,w=170,h=80,color='D',font=60,fText=CHAR.icon.back,code=pressKey'escape'}, + WIDGET.newKey{name='back',x=1140,y=60,w=170,h=80,color='D',font=60,fText=CHAR.icon.back,code=backScene}, } return scene diff --git a/parts/scenes/customGame.lua b/parts/scenes/customGame.lua index 9eab4720..7cb767de 100644 --- a/parts/scenes/customGame.lua +++ b/parts/scenes/customGame.lua @@ -32,44 +32,46 @@ function scene.sceneInit() BGM.play(CUSTOMENV.bgm) end function scene.sceneBack() + saveFile(CUSTOMENV,'conf/customEnv') BGM.play() end -function scene.keyDown(key,isRep) - if isRep then return end - if key=='return'or key=='return2'then - if CUSTOMENV.opponent~="X"then - if CUSTOMENV.opponent:sub(1,2)=='CC'then - if CUSTOMENV.sequence=='fixed'then - MES.new('error',text.cc_fixed) - return - end - if CUSTOMENV.holdMode=='swap'then - MES.new('error',text.cc_swap) - return - end +local function _play(mode) + if CUSTOMENV.opponent~="X"then + if CUSTOMENV.opponent:sub(1,2)=='CC'then + if CUSTOMENV.sequence=='fixed'then + MES.new('error',text.cc_fixed) + return end - if #BAG>0 then - for _=1,#BAG do - if BAG[_]>7 then - MES.new('error',text.ai_prebag) - return - end - end - end - if #MISSION>0 then - MES.new('error',text.ai_mission) + if CUSTOMENV.holdMode=='swap'then + MES.new('error',text.cc_swap) return end end - if key=='return2'or kb.isDown('lalt','lctrl','lshift')then - if #FIELD[1]>0 then - saveFile(CUSTOMENV,'conf/customEnv') - loadGame('custom_puzzle',true) + if #BAG>0 then + for _=1,#BAG do + if BAG[_]>7 then + MES.new('error',text.ai_prebag) + return + end end - else - saveFile(CUSTOMENV,'conf/customEnv') - loadGame('custom_clear',true) + end + if #MISSION>0 then + MES.new('error',text.ai_mission) + return + end + end + saveFile(CUSTOMENV,'conf/customEnv') + loadGame('custom_'..mode,true) +end + +function scene.keyDown(key,isRep) + if isRep then return true end + if key=='return'and kb.isDown('lctrl','lalt')then + if kb.isDown('lalt')and #FIELD[1]>0 then + _play('puzzle') + elseif kb.isDown('lctrl')then + _play('clear') end elseif key=='f'then SCN.go('custom_field','swipeD') @@ -122,11 +124,8 @@ function scene.keyDown(key,isRep) MES.new('check',text.importSuccess) do return end ::THROW_fail::MES.new('error',text.dataCorrupted) - elseif key=='escape'then - saveFile(CUSTOMENV,'conf/customEnv') - SCN.back() else - WIDGET.keyPressed(key) + return true end end diff --git a/parts/scenes/dict.lua b/parts/scenes/dict.lua index 78d224fd..2b051a08 100644 --- a/parts/scenes/dict.lua +++ b/parts/scenes/dict.lua @@ -124,8 +124,6 @@ function scene.keyDown(key) inputBox:clear() SFX.play('hold') end - elseif key=='backspace'then - WIDGET.keyPressed("backspace") elseif key=='escape'then if inputBox:hasText()then scene.keyDown('delete') @@ -143,7 +141,7 @@ function scene.keyDown(key) if not WIDGET.isFocus(inputBox)then WIDGET.focus(inputBox) end - WIDGET.keyPressed(key) + return true end end diff --git a/parts/scenes/main.lua b/parts/scenes/main.lua index 2e69643b..d993cd4b 100644 --- a/parts/scenes/main.lua +++ b/parts/scenes/main.lua @@ -46,76 +46,9 @@ function scene.mouseDown(x,y) end end scene.touchDown=scene.mouseDown -local function _testButton(n) - if NET.getlock('access_and_login')then - MES.new('warn',text.wsConnecting) - else - if WIDGET.isFocus(scene.widgetList[n])then - return true - else - WIDGET.focus(scene.widgetList[n]) - end - end -end function scene.keyDown(key,isRep) - if isRep then return end - if key=='1'then - if _testButton(1)then - SCN.go('mode') - end - elseif key=='q'then - if _testButton(2)then - loadGame(STAT.lastPlay,true) - end - elseif key=='a'then - if _testButton(3)then - if WS.status('app')=='running'then - NET.tryLogin(false) - elseif WS.status('app')=='dead'then - NET.wsconn_app() - SFX.play('connect') - MES.new('info',text.wsConnecting) - end - end - elseif key=='z'then - if _testButton(4)then - SCN.go('customGame') - end - elseif key=='-'then - if _testButton(5)then - SCN.go('setting_game') - end - elseif key=='p'then - if _testButton(6)then - SCN.go('stat') - end - elseif key=='l'then - if _testButton(7)then - SCN.go('dict') - end - elseif key==','then - if _testButton(8)then - SCN.go('replays') - end - elseif key=='2'then - if _testButton(9)then - SCN.go('music') - end - elseif key=='3'then - if _testButton(10)then - SCN.go('lang') - end - elseif key=='x'then - if _testButton(11)then - SCN.go('about') - end - elseif key=='m'then - if _testButton(12)then - SCN.go('manual') - end - elseif key=='c'then - enterConsole() - elseif key=='escape'then + if isRep then return true end + if key=='escape'then if TIME()-lastQuitTime<1 then VOC.play('bye') SCN.swapTo('quit','slowFade') @@ -123,6 +56,10 @@ function scene.keyDown(key,isRep) lastQuitTime=TIME() MES.new('warn',text.sureQuit) end + elseif key=='c'then + enterConsole() + else + return true end end @@ -183,21 +120,36 @@ function scene.draw() end end +local function notConn() + if NET.getlock('access_and_login')then + MES.new('warn',text.wsConnecting) + else + return true + end +end scene.widgetList={ - WIDGET.newButton{name='offline',x=-1200,y=210,w=800,h=100,color='lR',font=45,align='R',edge=30,code=pressKey'1'}, - WIDGET.newButton{name='qplay', x=-1200,y=330,w=800,h=100,color='lM',font=40,align='R',edge=30,code=pressKey'q'}, - WIDGET.newButton{name='online', x=-1200,y=450,w=800,h=100,color='lV',font=45,align='R',edge=30,code=pressKey'a'}, - WIDGET.newButton{name='custom', x=-1200,y=570,w=800,h=100,color='lS',font=45,align='R',edge=30,code=pressKey'z'}, + WIDGET.newButton{name='offline',x=-1200,y=210,w=800,h=100,color='lR',font=45,align='R',edge=30,code=function()if notConn()then SCN.go('mode')end end}, + WIDGET.newButton{name='qplay', x=-1200,y=330,w=800,h=100,color='lM',font=40,align='R',edge=30,code=function()loadGame(STAT.lastPlay,true)end}, + WIDGET.newButton{name='online', x=-1200,y=450,w=800,h=100,color='lV',font=45,align='R',edge=30,code=function() + if WS.status('app')=='running'then + NET.tryLogin(false) + elseif WS.status('app')=='dead'then + NET.wsconn_app() + SFX.play('connect') + MES.new('info',text.wsConnecting) + end + end}, + WIDGET.newButton{name='custom', x=-1200,y=570,w=800,h=100,color='lS',font=45,align='R',edge=30,code=function()if notConn()then SCN.go('customGame')end end}, - WIDGET.newButton{name='setting',x=2480,y=210,w=800,h=100, color='lO',font=40,align='L',edge=30,code=pressKey'-'}, - WIDGET.newButton{name='stat', x=2480,y=330,w=800,h=100, color='lL',font=40,align='L',edge=30,code=pressKey'p'}, - WIDGET.newButton{name='dict', x=2480,y=450,w=800,h=100, color='lG',font=40,align='L',edge=30,code=pressKey'l'}, - WIDGET.newButton{name='replays',x=2480,y=570,w=800,h=100, color='lC',font=40,align='L',edge=30,code=pressKey','}, + WIDGET.newButton{name='setting',x=2480,y=210,w=800,h=100, color='lO',font=40,align='L',edge=30,code=function()if notConn()then SCN.go('setting_game')end end}, + WIDGET.newButton{name='stat', x=2480,y=330,w=800,h=100, color='lL',font=40,align='L',edge=30,code=function()if notConn()then SCN.go('stat')end end}, + WIDGET.newButton{name='dict', x=2480,y=450,w=800,h=100, color='lG',font=40,align='L',edge=30,code=function()if notConn()then SCN.go('dict')end end}, + WIDGET.newButton{name='replays',x=2480,y=570,w=800,h=100, color='lC',font=40,align='L',edge=30,code=function()if notConn()then SCN.go('replays')end end}, - WIDGET.newButton{name='music', x=120,y=80,w=100, color='lO',code=pressKey'2',font=70,fText=CHAR.icon.music}, - WIDGET.newButton{name='lang', x=280,y=80,w=100, color='lN',code=pressKey'3',font=70,fText=CHAR.icon.language}, - WIDGET.newButton{name='about', x=-110,y=670,w=600,h=70, color='lB',align='R',edge=20,code=pressKey'x',font=50,fText=CHAR.icon.info}, - WIDGET.newButton{name='manual', x=1390,y=670,w=600,h=70, color='lR',align='L',edge=20,code=pressKey'm',font=50,fText=CHAR.icon.help}, + WIDGET.newButton{name='music', x=120,y=80,w=100, color='lO',code=function()if notConn()then SCN.go('music')end end,font=70,fText=CHAR.icon.music}, + WIDGET.newButton{name='lang', x=280,y=80,w=100, color='lN',code=function()if notConn()then SCN.go('lang')end end,font=70,fText=CHAR.icon.language}, + WIDGET.newButton{name='about', x=-110,y=670,w=600,h=70, color='lB',align='R',edge=20,code=function()if notConn()then SCN.go('about')end end,font=50,fText=CHAR.icon.info}, + WIDGET.newButton{name='manual', x=1390,y=670,w=600,h=70, color='lR',align='L',edge=20,code=function()if notConn()then SCN.go('manual')end end,font=50,fText=CHAR.icon.help}, } return scene diff --git a/parts/scenes/net_newRoom.lua b/parts/scenes/net_newRoom.lua index de67b930..bacf4b6d 100644 --- a/parts/scenes/net_newRoom.lua +++ b/parts/scenes/net_newRoom.lua @@ -53,16 +53,6 @@ function scene.sceneBack() BGM.play() end -function scene.keyDown(key) - if key=='return'then - _createRoom() - elseif key=='escape'then - SCN.back() - else - WIDGET.keyPressed(key) - end -end - scene.widgetScrollHeight=400 scene.widgetList={ WIDGET.newText{name='title',x=40,y=15,font=70,align='L'}, @@ -95,7 +85,7 @@ scene.widgetList={ --Capacity & Create & Back WIDGET.newSelector{name='capacity', x=1070,y=330,w=310,color='lY',list={2,3,4,5,7,10,17,31,49,99},disp=ROOMval('capacity'),code=ROOMsto('capacity')}, - WIDGET.newButton{name='create', x=1070,y=480,w=310,h=140,color='lN',font=40,code=pressKey'return'}, + WIDGET.newButton{name='create', x=1070,y=480,w=310,h=140,color='lN',font=40,code=_createRoom}, WIDGET.newButton{name='back', x=1140,y=640,w=170,h=80,font=60,fText=CHAR.icon.back,code=backScene}, --Special rules diff --git a/parts/scenes/net_rooms.lua b/parts/scenes/net_rooms.lua index 4ad78ffb..2afb39d9 100644 --- a/parts/scenes/net_rooms.lua +++ b/parts/scenes/net_rooms.lua @@ -61,31 +61,21 @@ function scene.sceneInit() end function scene.keyDown(key) - if NET.getlock('enterRoom')then return end - if WIDGET.sel~=passwordBox then - if key=='r'then - if fetchTimer<=7 then - _fetchRoom() - end - elseif key=='s'then - SCN.go('setting_game') - elseif key=='n'then - SCN.go('net_newRoom') - elseif key=='escape'then - SCN.back() - elseif roomList:getLen()>0 and key=='return'then - local R=roomList:getSel() - if NET.getlock('fetchRoom')or not R then return end - if R.roomInfo.version==VERSION.room then - NET.enterRoom(R,passwordBox.value) - else - MES.new('error',text.versionNotMatch) - end + if NET.getlock('enterRoom')then return true end + if key=='r'then + if fetchTimer<=7 then + _fetchRoom() + end + elseif roomList:getLen()>0 and(key=='join'or key=='return'and love.keyboard.isDown('lctrl','rctrl'))then + local R=roomList:getSel() + if NET.getlock('fetchRoom')or not R then return end + if R.roomInfo.version==VERSION.room then + NET.enterRoom(R,passwordBox.value) else - WIDGET.keyPressed(key) + MES.new('error',text.versionNotMatch) end else - WIDGET.keyPressed(key) + return true end end @@ -144,12 +134,12 @@ end scene.widgetList={ roomList, passwordBox, - WIDGET.newKey{name='setting', x=1200,y=160,w=90,h=90,font=60,fText=CHAR.icon.settings,code=pressKey's'}, + WIDGET.newKey{name='setting', x=1200,y=160,w=90,h=90,font=60,fText=CHAR.icon.settings,code=goScene'setting_game'}, WIDGET.newText{name='refreshing',x=450,y=240,font=45,hideF=function()return not NET.getlock('fetchRoom')end}, WIDGET.newText{name='noRoom', x=450,y=245,font=40,hideF=function()return roomList:getLen()>0 or NET.getlock('fetchRoom')end}, WIDGET.newKey{name='refresh', x=250,y=630,w=140,h=120,code=_fetchRoom,hideF=function()return fetchTimer>7 end}, - WIDGET.newKey{name='new', x=510,y=630,w=260,h=120,code=pressKey'n'}, - WIDGET.newKey{name='join', x=780,y=630,w=140,h=120,code=pressKey'return',hideF=function()return roomList:getLen()==0 or NET.getlock('enterRoom')end}, + WIDGET.newKey{name='new', x=510,y=630,w=260,h=120,code=goScene'net_newRoom'}, + WIDGET.newKey{name='join', x=780,y=630,w=140,h=120,code=pressKey'join',hideF=function()return roomList:getLen()==0 or NET.getlock('enterRoom')end}, WIDGET.newButton{name='back', x=1140,y=640,w=170,h=80,font=60,fText=CHAR.icon.back,code=pressKey'escape'}, } diff --git a/parts/scenes/pause.lua b/parts/scenes/pause.lua index 16f6f44a..02f781c7 100644 --- a/parts/scenes/pause.lua +++ b/parts/scenes/pause.lua @@ -121,7 +121,7 @@ function scene.sceneBack() end function scene.keyDown(key,isRep) - if isRep then return end + if isRep then return true end if key=='q'then SCN.back() GAME.playing=false @@ -165,7 +165,7 @@ function scene.keyDown(key,isRep) SYSFX.newShade(1.2,555,200,620,380,.6,.6,.6) end else - WIDGET.keyPressed(key) + return true end end diff --git a/parts/scenes/replays.lua b/parts/scenes/replays.lua index 00362ffb..3f1438dd 100644 --- a/parts/scenes/replays.lua +++ b/parts/scenes/replays.lua @@ -137,10 +137,8 @@ function scene.keyDown(key) MES.new('info',text.sureReset) end end - elseif key=='escape'then - SCN.back() else - WIDGET.keyPressed(key) + return true end end diff --git a/parts/scenes/setting_key.lua b/parts/scenes/setting_key.lua index a3b1a9ad..99b27d9b 100644 --- a/parts/scenes/setting_key.lua +++ b/parts/scenes/setting_key.lua @@ -31,7 +31,7 @@ local forbbidenKeys={ ["return"]=true, } function scene.keyDown(key,isRep) - if isRep then return end + if isRep then return true end if key=='escape'then if selected then selected=false @@ -57,7 +57,7 @@ function scene.keyDown(key,isRep) SFX.play('reach',.5) end else - WIDGET.keyPressed(key) + return true end end function scene.gamepadDown(key) @@ -80,14 +80,14 @@ function scene.gamepadDown(key) selected=false SFX.play('reach',.5) else - WIDGET.gamepadPressed(key) + return true end end function scene.draw() setFont(20) gc.setColor(COLOR.Z) - gc.printf(text.keySettingInstruction,540,620,500,'right') + gc.printf(text.keySettingInstruction,526,620,500,'right') for i=0,20 do for j=1,#keyList[i]do diff --git a/parts/scenes/setting_sound.lua b/parts/scenes/setting_sound.lua index 8e3e5d9c..3e16c8f9 100644 --- a/parts/scenes/setting_sound.lua +++ b/parts/scenes/setting_sound.lua @@ -38,10 +38,10 @@ end scene.touchDown=scene.mouseDown function scene.keyDown(key) - if key=='escape'then - SCN.back() - elseif key=='space'then + if key=='space'then scene.mouseDown(942,626) + else + return true end end diff --git a/parts/scenes/staff.lua b/parts/scenes/staff.lua index 450e6850..cd2bc3d3 100644 --- a/parts/scenes/staff.lua +++ b/parts/scenes/staff.lua @@ -31,12 +31,12 @@ end scene.touchDown=scene.mouseDown function scene.keyDown(key) - if key=='escape'then - SCN.back() - elseif key=='l'then + if key=='l'then loadGame('sprintLock',true) elseif key=='f'then loadGame('sprintFix',true) + else + return true end end diff --git a/parts/scenes/stat.lua b/parts/scenes/stat.lua index 1600faea..81c7353b 100644 --- a/parts/scenes/stat.lua +++ b/parts/scenes/stat.lua @@ -54,11 +54,11 @@ function scene.mouseDown(x,y) end end scene.touchDown=scene.mouseDown -function scene.keyDown(key) - if key=='escape'then - SCN.back() - elseif love.keyboard.isDown('m')and love.keyboard.isDown('d')then +function scene.keyDown() + if love.keyboard.isDown('m')and love.keyboard.isDown('d')then loadGame('sprintMD',true) + else + return true end end