From 55e76a52beee20b4e6672160a17ddaa5f47b4626 Mon Sep 17 00:00:00 2001 From: MrZ626 <1046101471@qq.com> Date: Wed, 27 Jan 2021 19:30:20 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8C=89=E9=94=AE=E6=9C=BA=E5=88=B6=E6=9B=B4?= =?UTF-8?q?=E6=94=B9=EF=BC=8C=E6=96=B0=E9=94=AE=E4=BD=8D=E8=AE=BE=E7=BD=AE?= =?UTF-8?q?=E8=8F=9C=E5=8D=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- main.lua | 4 + parts/globalTables.lua | 16 ++- parts/language/lang_en.lua | 31 ++++-- parts/language/lang_fr.lua | 31 ++++-- parts/language/lang_pt.lua | 31 ++++-- parts/language/lang_sp.lua | 32 ++++-- parts/language/lang_symbol.lua | 31 ++++-- parts/language/lang_zh.lua | 32 ++++-- parts/scenes/play.lua | 59 +++++----- parts/scenes/setting_key.lua | 194 ++++++++++++++++----------------- 10 files changed, 269 insertions(+), 192 deletions(-) diff --git a/main.lua b/main.lua index e6951706..beb5d5a8 100644 --- a/main.lua +++ b/main.lua @@ -348,6 +348,10 @@ do if needSaveRank then FILE.save(RANKS,"conf/unlock") end + if keyMap[1]then + NOGAME=true + fs.remove("conf/key") + end if STAT.version~=VERSION_CODE then newVersionLaunch=true STAT.version=VERSION_CODE diff --git a/parts/globalTables.lua b/parts/globalTables.lua index da958b8e..dcca3c57 100644 --- a/parts/globalTables.lua +++ b/parts/globalTables.lua @@ -334,11 +334,17 @@ else }for i=1,29 do STAT.clear[i]={0,0,0,0,0,0}STAT.spin[i]={0,0,0,0,0,0,0}end end keyMap=FILE.load("conf/key")or{--Key setting - {"left","right","x","z","c","up","down","space","a","s"},{}, - --Keyboard - {"dpleft","dpright","a","b","y","dpup","dpdown","rightshoulder","x","leftshoulder"},{}, - --Joystick -}for i=1,#keyMap do for j=1,20 do if not keyMap[i][j]then keyMap[i][j]=""end end end + keyboard={ + left=1,right=2,x=3,z=4,c=5, + up=6,down=7,space=8,a=9,s=10, + r=0, + }, + joystick={ + dpleft=1,dpright=2,a=3,b=4,y=5, + dpup=6,dpdown=7,rightshoulder=8,x=9, + leftshoulder=0, + }, +} VK_org=FILE.load("conf/virtualkey")or{--Virtualkey layout, refresh all VKs' position with this before each game {ava=true, x=80, y=720-200, r=80,color=COLOR.lame},--moveLeft {ava=true, x=320, y=720-200, r=80,color=COLOR.lame},--moveRight diff --git a/parts/language/lang_en.lua b/parts/language/lang_en.lua index a1b2e833..27cccd1b 100644 --- a/parts/language/lang_en.lua +++ b/parts/language/lang_en.lua @@ -130,13 +130,6 @@ return{ pushSpeed="Garbage speed\nOverride the speed at which garbage lines rise (unit: blocks/frame)", boneBlock="Bone\nPlay with the bone block skin", }, - acts={ - "Move Left:","Move Right:", - "Rotate Right:","Rotate Left:","Rotate 180°:", - "Hard Drop:","Soft Drop:","Hold:","Function1:","Function2:", - "Instant Left:","Instant Right:","Sonic Drop:","Down 1:","Down 4:","Down 10:", - "Left Drop:","Right Drop:","Left Zangi:","Right Zangi:", - }, pauseStat={ "Time:", "Key/Rot./Hold:", @@ -332,9 +325,27 @@ return{ reset="Reset", }, setting_key={ - keyboard="Keyboard", - joystick="Controller", - help="Arrow keys: select/change slot, Enter/Space: Change, Esc: Go back", + a1="Move Left", + a2="Move Right", + a3="Rotate Right", + a4="Rotate Left", + a5="Rotate 180°", + a6="Hard Drop", + a7="Soft Drop", + a8="Hold", + a9="Function1", + a10="Function2", + a11="Instant Left", + a12="Instant Right", + a13="Sonic Drop", + a14="Down 1", + a15="Down 4", + a16="Down 10", + a17="Left Drop", + a18="Right Drop", + a19="Left Zangi", + a20="Right Zangi", + restart="Retry", }, setting_skin={ title="Layout Settings", diff --git a/parts/language/lang_fr.lua b/parts/language/lang_fr.lua index cfcd559c..2ded2897 100644 --- a/parts/language/lang_fr.lua +++ b/parts/language/lang_fr.lua @@ -109,13 +109,6 @@ return{ -- modInstruction="", -- modInfo={},--See lang_en.lua - acts={ - "Déplacement vers la gauche :","Déplacement vers la droite :", - "Rotation vers la droite:","Rotation vers la gauche :","180° :", - "Chute instantanée :","Chute rapide :","Réserve :","Fonction1 :","Fonction2 :", - "Déplacement instantané vers la gauche :","Déplacement instantané vers la droite : ","Chute sonique :","Descendre de 1 :","Descendre de 4 :","Descendre de 10 :", - "Chute à gauche :","Chute à droite :","Zangi gauche :","Zangi droite :", - }, pauseStat={ "Temps :", "Touche/Rot./Réserve :", @@ -310,9 +303,27 @@ return{ reset="Réinitialisation", }, setting_key={ - keyboard="Clavier", - joystick="Manette", - help="Flèches directionelles : Sélectionner/changer paramètre, Enter/Space : Modifier, Echap : Retour", + a1="Déplacement vers la gauche", + a2="Déplacement vers la droite", + a3="Rotation vers la droite", + a4="Rotation vers la gauche", + a5="180°", + a6="Chute instantanée", + a7="Chute rapide", + a8="Réserve", + a9="Fonction1", + a10="Fonction2", + a11="Déplacement instantané vers la gauche", + a12="Déplacement instantané vers la droite :", + a13="Chute sonique", + a14="Descendre de 1", + a15="Descendre de 4", + a16="Descendre de 10", + a17="Chute à gauche", + a18="Chute à droite", + a19="Zangi gauche", + a20="Zangi droite", + restart="Réessayer", }, setting_skin={ title="Skin, orientations, etc.", diff --git a/parts/language/lang_pt.lua b/parts/language/lang_pt.lua index d1089a74..42f88745 100644 --- a/parts/language/lang_pt.lua +++ b/parts/language/lang_pt.lua @@ -129,13 +129,6 @@ return{ pushSpeed="Velocidade de lixo\nSobrepõe a velocidade que o lixo cresce (unidade: blocos/frame)", boneBlock="Bone\nJogue com blocos bone", }, - acts={ - "Esquerda:","Direita:", - "Gira direita:","Gira esquerda:","Gire 180°:", - "Queda dura:","Queda leve:","Segurar:","Função1:","Função2:", - "Esquerda imediata:","Direita imediata:","Queda sonic:","Queda 1:","Queda 4:","Queda 10:", - "Queda esquerda:","Queda direita:"," Zangi esquerda:","Zangi direita:", - }, pauseStat={ "Tempo:", "Tecla/Rot./Segurar:", @@ -331,9 +324,27 @@ return{ reset="Resetar", }, setting_key={ - keyboard="Teclado", - joystick="Controle Joystick", - help="Arrow keys: select/change slot, Enter/Space: Change, Esc: Go back", + a1="Esquerda", + a2="Direita", + a3="Gira direita", + a4="Gira esquerda", + a5="Gire 180°", + a6="Queda dura", + a7="Queda leve", + a8="Segurar", + a9="Função1", + a10="Função2", + a11="Esquerda imediata", + a12="Direita imediata", + a13="Queda sonic", + a14="Queda 1", + a15="Queda 4", + a16="Queda 10", + a17="Queda esquerda", + a18="Queda direita", + a19=" Zangi esquerda", + a20="Zangi direita", + restart="Reiniciar", }, setting_skin={ title="Config. Layout", diff --git a/parts/language/lang_sp.lua b/parts/language/lang_sp.lua index 89bcf70f..94082bdc 100644 --- a/parts/language/lang_sp.lua +++ b/parts/language/lang_sp.lua @@ -110,14 +110,6 @@ return{ -- modInstruction="", -- modInfo={},--See lang_en.lua - acts={ - "Mover a Izq.:","Mover a Der.:", - "Rotar Der.:","Rotar Izq.:","Rotar 180°:", - "Caída Instantánea:","Caída Rápida:", - "Reserva:","Función1:","Función2:", - "Izq. Instant.:","Der. Instant.:","Sonic Drop:","Abajo 1:","Abajo 4:","Abajo 10:", - "Caída a Izq.:","Caída a Der.:","Zangi a Izq.:","Zangi a Der.:", - }, pauseStat={ "Tiempo:", "Tecla/Rot./Reserva:", @@ -310,9 +302,27 @@ return{ reset="Reinicio", }, setting_key={ - keyboard="Teclado", - joystick="Joystick", - help="Flechas: Seleccionar/Cambiar slot, Enter/Espacio: Cambiar,Esc. Volver", + a1="Mover a Izq.", + a2="Mover a Der.", + a3="Rotar Der.", + a4="Rotar Izq.", + a5="Rotar 180°", + a6="Caída Instantánea", + a7="Caída Rápida", + a8="Reserva", + a9="Función1", + a10="Función2", + a11="Izq. Instant.", + a12="Der. Instant.", + a13="Sonic Drop", + a14="Abajo 1", + a15="Abajo 4", + a16="Abajo 10", + a17="Caída a Izq.", + a18="Caída a Der.", + a19="Zangi a Izq.", + a20="Zangi a Der.", + restart="Reiniciar", }, setting_skin={ title="Ajustes de Texturas", diff --git a/parts/language/lang_symbol.lua b/parts/language/lang_symbol.lua index 7f4ae206..40b51f07 100644 --- a/parts/language/lang_symbol.lua +++ b/parts/language/lang_symbol.lua @@ -53,13 +53,6 @@ return{ errorMsg="An e??o? h@s occ^__ed @nd Techmino n__ds to r_st@rt.\n&**o* in#o h@$ b==n cre@ted, @nd y0u c@n $&nd it to the @uth0r.", - acts={ - "←:","→:", - "R→:","←R:","R↑↓:", - "↓↓:","↓:","□←:","F1:","F2:", - "|←:","→|:","↓_:","↓1:","↓4:","↓10:", - "←↓→↓:","→↓↓:","←↓→↓:","→↓←↓:", - }, pauseStat={ "~:", "=/''/[ ]:", @@ -202,9 +195,27 @@ return{ reset="R", }, setting_key={ - keyboard="[##]", - joystick="^-^", - help="..........................", + a1="←", + a2="→", + a3="R→", + a4="←R", + a5="R↑↓", + a6="↓↓", + a7="↓", + a8="□←", + a9="F1", + a10="F2", + a11="|←", + a12="→|", + a13="↓_", + a14="↓1", + a15="↓4", + a16="↓10", + a17="←↓→↓", + a18="→↓↓", + a19="←↓→↓", + a20="→↓←↓", + restart="_→_", }, setting_skin={ title="%{~~}", diff --git a/parts/language/lang_zh.lua b/parts/language/lang_zh.lua index bba5d977..50d1172b 100644 --- a/parts/language/lang_zh.lua +++ b/parts/language/lang_zh.lua @@ -131,14 +131,6 @@ return{ pushSpeed="涨行速度:\n改变垃圾行升起的速度(单位:格/帧)", boneBlock="骨块:\n使用骨块进行游戏", }, - acts={ - "左移:","右移:", - "顺时针旋转:","逆时针旋转:","180°旋转:", - "硬降:","软降:", - "暂存:","功能键1:","功能键2:", - "左瞬移:","右瞬移:","软降到底:","软降一格:","软降四格:","软降十格:", - "落在最左:","落在最右:","列在最左:","列在最右:", - }, pauseStat={ "时间:", "按键/旋转/暂存:", @@ -333,9 +325,27 @@ return{ reset="重置", }, setting_key={ - keyboard="键盘", - joystick="手柄", - help="方向键选择/翻页,回车/空格修改,esc返回", + a1="左移", + a2="右移", + a3="顺时针旋转", + a4="逆时针旋转", + a5="180°旋转", + a6="硬降", + a7="软降", + a8="暂存", + a9="功能键1", + a10="功能键2", + a11="左瞬移", + a12="右瞬移", + a13="软降到底", + a14="软降一格", + a15="软降四格", + a16="软降十格", + a17="落在最左", + a18="落在最右", + a19="列在最左", + a20="列在最右", + restart="重新开始", }, setting_skin={ title="外观设置", diff --git a/parts/scenes/play.lua b/parts/scenes/play.lua index c044822b..0c3864a1 100644 --- a/parts/scenes/play.lua +++ b/parts/scenes/play.lua @@ -38,6 +38,9 @@ function scene.sceneInit() end scene.mouseDown=NULL +local function restart() + resetGameData(GAME.frame<240 and"q") +end function scene.touchDown(_,x,y) if noTouch then return end @@ -101,56 +104,56 @@ function scene.touchMove() end end function scene.keyDown(key) - if key=="escape"then - pauseGame() - elseif not noKey then - local m=keyMap - for k=1,20 do - if key==m[1][k]or key==m[2][k]then - PLAYERS[1]:pressKey(k) - VK[k].isDown=true - VK[k].pressTime=10 - return - end + local k=keyMap.keyboard[key] + if k then + if k>0 then + PLAYERS[1]:pressKey(k) + VK[k].isDown=true + VK[k].pressTime=10 + else + restart() end + elseif key=="escape"then + pauseGame() end end function scene.keyUp(key) if noKey then return end - local m=keyMap - for k=1,20 do - if key==m[1][k]or key==m[2][k]then + local k=keyMap.keyboard[key] + if k then + if k>0 then PLAYERS[1]:releaseKey(k) VK[k].isDown=false - return end + elseif key=="back"then + pauseGame() end end function scene.gamepadDown(key) if noKey then return end - - local m=keyMap - for k=1,20 do - if key==m[3][k]or key==m[4][k]then + local k=keyMap.joystick[key] + if k then + if k>0 then PLAYERS[1]:pressKey(k) VK[k].isDown=true VK[k].pressTime=10 - return + else + restart() end + elseif key=="back"then + pauseGame() end - - if key=="back"then pauseGame()end end function scene.gamepadUp(key) if noKey then return end - - local m=keyMap - for k=1,20 do - if key==m[3][k]or key==m[4][k]then + local k=keyMap.joystick[key] + if k then + if k>0 then PLAYERS[1]:releaseKey(k) VK[k].isDown=false - return end + elseif key=="back"then + pauseGame() end end @@ -361,7 +364,7 @@ function scene.draw() gc.pop() end scene.widgetList={ - WIDGET.newKey{name="restart",fText="R",x=45,y=45,w=60,font=40,code=function()resetGameData(GAME.frame<240 and"q")end}, + WIDGET.newKey{name="restart",fText="R",x=45,y=45,w=60,font=40,code=restart}, WIDGET.newKey{name="pause",fText="II",x=1235,y=45,w=60,font=40,code=function()pauseGame()end}, } diff --git a/parts/scenes/setting_key.lua b/parts/scenes/setting_key.lua index 03638718..dae2d691 100644 --- a/parts/scenes/setting_key.lua +++ b/parts/scenes/setting_key.lua @@ -1,17 +1,26 @@ local gc=love.graphics -local int,sin=math.floor,math.sin local mStr=mStr +local ins=table.insert local scene={} -local page -local kb,js--Selected -local kS,jS--If setting +local selected--if waiting for key +local keyList + +local function freshKeyList() + keyList={}for i=0,20 do keyList[i]={}end + for k,v in next,keyMap.keyboard do + ins(keyList[v],{COLOR.lB,k}) + end + for k,v in next,keyMap.joystick do + ins(keyList[v],{COLOR.lR,k}) + end +end function scene.sceneInit() - page=1 - kb,js=1,1 - kS,jS=false,false + selected=false + freshKeyList() + BG.set("none") end function scene.sceneBack() FILE.save(keyMap,"conf/key") @@ -19,123 +28,114 @@ end function scene.keyDown(key) if key=="escape"then - if kS then - kS=false + if selected then + for k,v in next,keyMap.keyboard do + if v==selected then + keyMap.keyboard[k]=nil + end + end + freshKeyList() + selected=false SFX.play("finesseError",.5) else SCN.back() end - elseif kS then + elseif selected then if key~="\\"then - for y=1,20 do - if keyMap[1][y]==key then keyMap[1][y]=""break end - if keyMap[2][y]==key then keyMap[2][y]=""break end - end - keyMap[page][kb]=key - kS=false + keyMap.keyboard[key]=selected + freshKeyList() + selected=false SFX.play("reach",.5) end - elseif key=="return"or key=="space"then - kS=true - SFX.play("lock",.5) - elseif key=="up"or key=="w"then - if kb>1 then - kb=kb-1 - SFX.play("move",.5) - end - elseif key=="down"or key=="s"then - if kb<20 then - kb=kb+1 - SFX.play("move",.5) - end - elseif key=="left"or key=="a"or key=="right"or key=="d"then - page=3-page - SFX.play("rotate",.5) + else + WIDGET.keyPressed(key) end end function scene.gamepadDown(key) if key=="back"then - if jS then - jS=false + if selected then + for k,v in next,keyMap.joystick do + if v==selected then + keyMap.joystick[k]=nil + end + end + freshKeyList() + selected=false SFX.play("finesseError",.5) else SCN.back() end - elseif jS then - for y=1,20 do - if keyMap[3][y]==key then keyMap[3][y]=""break end - if keyMap[4][y]==key then keyMap[4][y]=""break end - end - keyMap[2+page][js]=key + elseif selected then + keyMap.joystick[key]=selected + freshKeyList() + selected=false SFX.play("reach",.5) - jS=false - elseif key=="start"then - jS=true - SFX.play("lock",.5) - elseif key=="dpup"then - if js>1 then - js=js-1 - SFX.play("move",.5) - end - elseif key=="dpdown"then - if js<20 then - js=js+1 - SFX.play("move",.5) - end - elseif key=="dpleft"or key=="dpright"then - page=3-page - SFX.play("rotate",.5) + else + WIDGET.gamepadPressed(key) end end function scene.draw() - local a=.3+sin(TIME()*15)*.1 - if kS then gc.setColor(1,.3,.3,a)else gc.setColor(1,.7,.7,a)end - gc.rectangle("fill", - kb<11 and 240 or 840, - 45*kb+20-450*int(kb/11), - 200,45 - ) - if jS then gc.setColor(.3,.3,.1,a)else gc.setColor(.7,.7,1,a)end - gc.rectangle("fill", - js<11 and 440 or 1040, - 45*js+20-450*int(js/11), - 200,45 - ) - --Selection rect - + setFont(15) gc.setColor(1,1,1) - setFont(25) - local b1,b2=keyMap[page],keyMap[page+2] - for N=1,20 do - if N<11 then - gc.printf(text.acts[N],47,45*N+22,180,"right") - mStr(b1[N],340,45*N+24) - mStr(b2[N],540,45*N+24) - else - gc.printf(text.acts[N],647,45*N-428,180,"right") - mStr(b1[N],940,45*N-426) - mStr(b2[N],1040,45*N-426) + + for i=0,20 do + for j=1,#keyList[i]do + local key=keyList[i][j] + local font=#key[2]==1 and 40 or #key[2]<6 and 30 or 15 + setFont(font) + mStr(key, + (i>10 and 940 or 210)+100*j, + i>10 and 60*(i-10)-23-font*.7 or + i>0 and 60*i-23-font*.7 or + 667-font*.7 + ) end end - gc.setLineWidth(2) - for x=40,1240,200 do - gc.line(x,65,x,515) + + if selected then + gc.setColor(COLOR[TIME()%.26<.13 and"R"or"Y"]) + local x,y=selected>10 and 910 or 270, selected>10 and 60*(selected-10)-50 or selected>0 and 60*selected-50 or 630 + setFont(40)gc.print("=",x,y) + setFont(10)gc.print("esc?",x,y+40) end - for y=65,515,45 do - gc.line(40,y,1240,y) - end - setFont(35) - gc.print(text.page..page,280,570) end +local function setSel(i) + if selected==i then + selected=false + SFX.play("rotate",.5) + else + selected=i + SFX.play("lock",.5) + end +end scene.widgetList={ - WIDGET.newText{name="keyboard", x=340,y=30,font=25,color="lRed"}, - WIDGET.newText{name="keyboard", x=940,y=30,font=25,color="lRed"}, - WIDGET.newText{name="joystick", x=540,y=30,font=25,color="lBlue"}, - WIDGET.newText{name="joystick", x=1140,y=30,font=25,color="lBlue"}, - WIDGET.newText{name="help", x=50,y=650,font=30,align="L"}, - WIDGET.newButton{name="back", x=1140,y=640,w=170,h=80,font=40,code=backScene}, + WIDGET.newKey{name="a1", x=160,y=40,w=200,h=60,code=function()setSel(1)end}, + WIDGET.newKey{name="a2", x=160,y=100,w=200,h=60,code=function()setSel(2)end}, + WIDGET.newKey{name="a3", x=160,y=160,w=200,h=60,code=function()setSel(3)end}, + WIDGET.newKey{name="a4", x=160,y=220,w=200,h=60,code=function()setSel(4)end}, + WIDGET.newKey{name="a5", x=160,y=280,w=200,h=60,code=function()setSel(5)end}, + WIDGET.newKey{name="a6", x=160,y=340,w=200,h=60,code=function()setSel(6)end}, + WIDGET.newKey{name="a7", x=160,y=400,w=200,h=60,code=function()setSel(7)end}, + WIDGET.newKey{name="a8", x=160,y=460,w=200,h=60,code=function()setSel(8)end}, + WIDGET.newKey{name="a9", x=160,y=520,w=200,h=60,code=function()setSel(9)end}, + WIDGET.newKey{name="a10", x=160,y=580,w=200,h=60,code=function()setSel(10)end}, + + WIDGET.newKey{name="a11", x=800,y=40,w=200,h=60,code=function()setSel(11)end}, + WIDGET.newKey{name="a12", x=800,y=100,w=200,h=60,code=function()setSel(12)end}, + WIDGET.newKey{name="a13", x=800,y=160,w=200,h=60,code=function()setSel(13)end}, + WIDGET.newKey{name="a14", x=800,y=220,w=200,h=60,code=function()setSel(14)end}, + WIDGET.newKey{name="a15", x=800,y=280,w=200,h=60,code=function()setSel(15)end}, + WIDGET.newKey{name="a16", x=800,y=340,w=200,h=60,code=function()setSel(16)end}, + WIDGET.newKey{name="a17", x=800,y=400,w=200,h=60,code=function()setSel(17)end}, + WIDGET.newKey{name="a18", x=800,y=460,w=200,h=60,code=function()setSel(18)end}, + WIDGET.newKey{name="a19", x=800,y=520,w=200,h=60,code=function()setSel(19)end}, + WIDGET.newKey{name="a20", x=800,y=580,w=200,h=60,code=function()setSel(20)end}, + + WIDGET.newKey{name="restart",x=160,y=670,w=200,h=60,code=function()setSel(0)end}, + + WIDGET.newButton{name="back",x=1140,y=640,w=190,h=80,font=40,code=backScene}, } return scene \ No newline at end of file