允许用键盘编辑序列

This commit is contained in:
MrZ_26
2020-07-17 17:37:48 +08:00
parent f29fc7081a
commit 7b35d69be1
6 changed files with 91 additions and 65 deletions

View File

@@ -24,7 +24,7 @@ local gc,sys=love.graphics,love.system
local Timer=love.timer.getTime
local int,rnd,max,min=math.floor,math.random,math.max,math.min
local abs=math.abs
local rem=table.remove
local ins,rem=table.insert,table.remove
local scr=scr
local xOy=love.math.newTransform()
@@ -314,6 +314,8 @@ function keyDown.custom(key)
elseif sel==13 then
BGM.play(customRange.bgm[customSel[sel]])
end
elseif key=="q"then
SCN.goto("sequence")
elseif #key==1 then
local T=tonumber(key)
if T and T>=1 and T<=5 then
@@ -328,25 +330,50 @@ function keyDown.custom(key)
end
end
local minoKey={
["1"]=1,["2"]=2,["3"]=3,["4"]=4,["5"]=5,["6"]=6,["7"]=7,
z=1,s=2,j=3,l=4,t=5,o=6,i=7,
p=10,q=11,f=12,e=13,u=15,
v=16,w=17,x=18,r=21,y=22,n=23,h=24,
}
local minoKey2={
["1"]=8,["2"]=9,["3"]=19,["4"]=20,["5"]=14,["7"]=25,
z=8,s=9,t=14,j=19,l=20,i=25
}
function keyDown.sequence(key)
local s=sceneTemp
if key=="left"then
if s.cur>0 then s.cur=s.cur-1 end
elseif key=="right"then
if s.cur<#preBag then s.cur=s.cur+1 end
elseif key=="backspace"then
local C=s.cur
if C>0 then
rem(preBag,C)
s.cur=C-1
if type(key)=="number"then
local C=s.cur+1
ins(preBag,C,key)
s.cur=C
elseif #key==1 then
local i=(kb.isDown("lctrl","lshift","lalt","rctrl","rshift","ralt")and minoKey2 or minoKey)[key]
if i then
local C=s.cur+1
ins(preBag,C,i)
s.cur=C
end
elseif key=="delete"then
if sceneTemp.sure>20 then
preBag={1,2,3,4,5,6,7}
sceneTemp.cur=7
sceneTemp.sure=0
else
sceneTemp.sure=50
else
if key=="left"then
if s.cur>0 then s.cur=s.cur-1 end
elseif key=="right"then
if s.cur<#preBag then s.cur=s.cur+1 end
elseif key=="backspace"then
local C=s.cur
if C>0 then
rem(preBag,C)
s.cur=C-1
end
elseif key=="escape"then
SCN.back()
elseif key=="delete"then
if sceneTemp.sure>20 then
preBag={}
sceneTemp.cur=7
sceneTemp.sure=0
else
sceneTemp.sure=50
end
end
end
end

View File

@@ -210,7 +210,7 @@ local langList={
set3="无尽(3)",
set4="隐形(4)",
set5="极限(5)",
seq="高级设置",
seq="高级设置(q)",
draw="初始场地编辑",
back="返回",
},
@@ -648,7 +648,7 @@ local langList={
set3="无尽(3)",
set4="隐形(4)",
set5="极限(5)",
seq="高级设置",
seq="高级设置(q)",
draw="初始场地编辑",
back="返回",
},
@@ -1075,7 +1075,7 @@ local langList={
set3="Inf. (3)",
set4="Blind (4)",
set5="Master (5)",
seq="Advanced",
seq="Advanced(q)",
draw="Field Edit",
back="Back",
},
@@ -1502,7 +1502,7 @@ local langList={
set3="Inf. (3)",
set4="Blind (4)",
set5="Master (5)",
seq="Advanced",
seq="Advanced(q)",
draw="Field Edit",
back="X",
},

View File

@@ -86,7 +86,6 @@ local function nextDir(n) return function()SKIN.rotate(n) end end
local function VKAdisp(n) return function()return VK_org[n].ava end end
local function VKAcode(n) return function()VK_org[n].ava=not VK_org[n].ava end end
local function setLang(n) return function()LANG.set(n)setting.lang=n end end
local function SEQpush(n) return function()local C=sceneTemp.cur+1 ins(preBag,C,n)sceneTemp.cur=C end end
local newButton,newSwitch,newSlider=WIDGET.new.button,WIDGET.new.switch,WIDGET.new.slider
@@ -127,37 +126,37 @@ local Widgets={
set4= newButton(940, 560,260,70, C.lightYellow, 32,pressKey("4")),
set5= newButton(940, 640,260,70, C.lightYellow, 32,pressKey("5")),
seq= newButton(665, 415,162,40, C.lightGreen, 32,function()SCN.goto("sequence")end),
seq= newButton(665, 415,200,40, C.lightGreen, 30,function()SCN.goto("sequence")end),
draw= newButton(150, 80, 220,80, C.white, 35,function()SCN.swapTo("draw")end),
back= newButton(1200, 640,120,120,C.white, 35,BACK),
},
sequence={
Z= newButton(150, 440,90, 90,C.white, 50,SEQpush(1)),
S= newButton(250, 440,90, 90,C.white, 50,SEQpush(2)),
J= newButton(350, 440,90, 90,C.white, 50,SEQpush(3)),
L= newButton(450, 440,90, 90,C.white, 50,SEQpush(4)),
T= newButton(550, 440,90, 90,C.white, 50,SEQpush(5)),
O= newButton(650, 440,90, 90,C.white, 50,SEQpush(6)),
I= newButton(750, 440,90, 90,C.white, 50,SEQpush(7)),
Z= newButton(150, 440,90, 90,C.white, 50,pressKey(1)),
S= newButton(250, 440,90, 90,C.white, 50,pressKey(2)),
J= newButton(350, 440,90, 90,C.white, 50,pressKey(3)),
L= newButton(450, 440,90, 90,C.white, 50,pressKey(4)),
T= newButton(550, 440,90, 90,C.white, 50,pressKey(5)),
O= newButton(650, 440,90, 90,C.white, 50,pressKey(6)),
I= newButton(750, 440,90, 90,C.white, 50,pressKey(7)),
Z5= newButton(150, 540,90, 90,C.white, 50,SEQpush(8)),
S5= newButton(250, 540,90, 90,C.white, 50,SEQpush(9)),
P= newButton(350, 540,90, 90,C.white, 50,SEQpush(10)),
Q= newButton(450, 540,90, 90,C.white, 50,SEQpush(11)),
F= newButton(550, 540,90, 90,C.white, 50,SEQpush(12)),
E= newButton(650, 540,90, 90,C.white, 50,SEQpush(13)),
T5= newButton(750, 540,90, 90,C.white, 50,SEQpush(14)),
U= newButton(850, 540,90, 90,C.white, 50,SEQpush(15)),
V= newButton(950, 540,90, 90,C.white, 50,SEQpush(16)),
W= newButton(150, 640,90, 90,C.white, 50,SEQpush(17)),
X= newButton(250, 640,90, 90,C.white, 50,SEQpush(18)),
J5= newButton(350, 640,90, 90,C.white, 50,SEQpush(19)),
L5= newButton(450, 640,90, 90,C.white, 50,SEQpush(20)),
R= newButton(550, 640,90, 90,C.white, 50,SEQpush(21)),
Y= newButton(650, 640,90, 90,C.white, 50,SEQpush(22)),
N= newButton(750, 640,90, 90,C.white, 50,SEQpush(23)),
H= newButton(850, 640,90, 90,C.white, 50,SEQpush(24)),
I5= newButton(950, 640,90, 90,C.white, 50,SEQpush(25)),
Z5= newButton(150, 540,90, 90,C.white, 50,pressKey(8)),
S5= newButton(250, 540,90, 90,C.white, 50,pressKey(9)),
P= newButton(350, 540,90, 90,C.white, 50,pressKey(10)),
Q= newButton(450, 540,90, 90,C.white, 50,pressKey(11)),
F= newButton(550, 540,90, 90,C.white, 50,pressKey(12)),
E= newButton(650, 540,90, 90,C.white, 50,pressKey(13)),
T5= newButton(750, 540,90, 90,C.white, 50,pressKey(14)),
U= newButton(850, 540,90, 90,C.white, 50,pressKey(15)),
V= newButton(950, 540,90, 90,C.white, 50,pressKey(16)),
W= newButton(150, 640,90, 90,C.white, 50,pressKey(17)),
X= newButton(250, 640,90, 90,C.white, 50,pressKey(18)),
J5= newButton(350, 640,90, 90,C.white, 50,pressKey(19)),
L5= newButton(450, 640,90, 90,C.white, 50,pressKey(20)),
R= newButton(550, 640,90, 90,C.white, 50,pressKey(21)),
Y= newButton(650, 640,90, 90,C.white, 50,pressKey(22)),
N= newButton(750, 640,90, 90,C.white, 50,pressKey(23)),
H= newButton(850, 640,90, 90,C.white, 50,pressKey(24)),
I5= newButton(950, 640,90, 90,C.white, 50,pressKey(25)),
left= newButton(850, 440,90, 90,C.lightGreen, 55,pressKey("left")),
right= newButton(950, 440,90, 90,C.lightGreen, 55,pressKey("right")),
@@ -189,8 +188,8 @@ local Widgets={
space= newButton(730, 360,120,120,C.grey, 65,setPen(-1)),
clear= newButton(1200, 500,120,120,C.white, 40,pressKey("delete")),
demo= newSwitch(755, 640,30,function()return sceneTemp.demo end,function()sceneTemp.demo=not sceneTemp.demo end),
copy= newButton(920, 640,120,120,C.lightRed, 35,copyBoard),
paste= newButton(1060, 640,120,120,C.lightBlue, 35,pasteBoard),
copy= newButton(920, 640,120,120,C.lightRed, 35,function()copyBoard()end),
paste= newButton(1060, 640,120,120,C.lightBlue, 35,function()pasteBoard()end),
custom= newButton(110, 80, 140,80, C.white, 35,function()SCN.goto("custom")end),
back= newButton(1200, 640,120,120,C.white, 35,BACK),
},
@@ -211,20 +210,20 @@ local Widgets={
quit= newButton(640,600,240,100,C.white,35,BACK),
},
setting_game={
graphic=newButton(200,80,240,80,C.lightCyan,35,function()SCN.swapTo("setting_video")end, nil,"sound"),
sound= newButton(1080,80,240,80,C.lightCyan,35,function()SCN.swapTo("setting_sound")end, nil,"ctrl"),
graphic=newButton(200,80,240,80,C.lightCyan,35,function()SCN.swapTo("setting_video")end, nil,"sound"),
sound= newButton(1080,80,240,80,C.lightCyan,35,function()SCN.swapTo("setting_sound")end, nil,"ctrl"),
ctrl= newButton(290,220,320,80,C.lightYellow,35,function()SCN.goto("setting_control")end, nil,"key"),
key= newButton(640,220,320,80,C.lightGreen,35,function()SCN.goto("setting_key")end, nil,"touch"),
touch= newButton(990,220,320,80,C.lightBlue,35,function()SCN.goto("setting_touch")end, nil,"reTime"),
reTime= newSlider(350,340,300,10,30,nil, SETval("reTime"), SETsto("reTime"), nil,"maxNext"),
maxNext=newSlider(350,440,300,6,30,nil, SETval("maxNext"), SETsto("maxNext"), nil,"autoPause"),
autoPause=newSwitch(350,540,20, SETval("autoPause"), SETrev("autoPause"), nil,"layout"),
reTime= newSlider(350,340,300,10,30,nil, SETval("reTime"), SETsto("reTime"), nil,"maxNext"),
maxNext=newSlider(350,440,300,6,30,nil, SETval("maxNext"), SETsto("maxNext"), nil,"autoPause"),
autoPause=newSwitch(350,540,20, SETval("autoPause"), SETrev("autoPause"), nil,"layout"),
layout= newButton(590,540,140,70,C.white,35,function()
SCN.goto("setting_skin")
end,nil,"quickR"),
quickR= newSwitch(1050,340,35, SETval("quickR"), SETrev("quickR"), nil,"swap"),
swap= newSwitch(1050,440,19, SETval("swap"), SETrev("swap"), nil,"fine"),
fine= newSwitch(1050,540,20, SETval("fine"), SETrev("fine"), nil,"back"),
quickR= newSwitch(1050,340,35, SETval("quickR"), SETrev("quickR"), nil,"swap"),
swap= newSwitch(1050,440,19, SETval("swap"), SETrev("swap"), nil,"fine"),
fine= newSwitch(1050,540,20, SETval("fine"), SETrev("fine"), nil,"back"),
back= newButton(1140,650,200,80,C.white,40,BACK, nil,"graphic"),
},
setting_video={
@@ -261,10 +260,10 @@ local Widgets={
setting_sound={
game= newButton(200,80,240,80,C.lightCyan,35,function()SCN.swapTo("setting_game")end, nil,"graphic"),
graphic=newButton(1080,80,240,80,C.lightCyan,35,function()SCN.swapTo("setting_video")end, nil,"sfx"),
sfx= newSlider(180,250,400,10,35,function()SFX.play("blip_1")end, SETval("sfx"), SETsto("sfx"), nil,"bgm"),
bgm= newSlider(750,250,400,10,35,function()BGM.freshVolume()end, SETval("bgm"), SETsto("bgm"), nil,"vib"),
vib= newSlider(180,440,400,5 ,28,function()VIB(2)end, SETval("vib"), SETsto("vib"), nil,"voc"),
voc= newSlider(750,440,400,10,32,function()VOC.play("nya")end, SETval("voc"), SETsto("voc"), nil,"stereo"),
sfx= newSlider(180,250,400,10,35,function()SFX.play("blip_1")end, SETval("sfx"), SETsto("sfx"), nil,"bgm"),
bgm= newSlider(750,250,400,10,35,function()BGM.freshVolume()end, SETval("bgm"), SETsto("bgm"), nil,"vib"),
vib= newSlider(180,440,400,5 ,28,function()VIB(2)end, SETval("vib"), SETsto("vib"), nil,"voc"),
voc= newSlider(750,440,400,10,32,function()VOC.play("nya")end, SETval("voc"), SETsto("voc"), nil,"stereo"),
stereo= newSlider(180,630,400,10,35,function()SFX.play("move",1,-1)SFX.play("lock",1,1)end, SETval("stereo"), SETsto("stereo"),function()return setting.sfx==0 end,"back"),
back= newButton(1140,650,200,80,C.white,40,BACK,nil,"game"),
},